Friday, November 27, 2009

Why does my CSS code not work in Opera like IE?

I am using an external style sheet and the code works great in IE, but it doesn't work in Opera. There's just one bit that isn't working. What I am trying to do is put a dashed border around a table. The code I am using is:



p.table-general {border-style: dotted; color: #CECF9C; }



Can anyone help me with this?



Why does my CSS code not work in Opera like IE?web browser





If you want to have a dashed border, you should use "dashed" not "dotted".



second problem, according to your css snippet, you have your table embeded into a paragraph, which is not correct html. You cannot have a table within a paragraph (although a paragraph within a table is fine).



third, Opera is very picky with code. if you have any error in it, it won't try as hard to guess what you meant (and this _is_ a good thing!).



Validate both your html and css code (check out w3c validators).



Ok, back on topic, the exact reason it doesn't work is that you didn't say how thick the border should be nor its color. No wonder nothing shows up. Here's a working example:



%26lt;p%26gt;paragraph%26lt;/p%26gt;



%26lt;table class="table-general"%26gt;



%26lt;tr%26gt;



%26lt;td%26gt;%26lt;/td%26gt;



%26lt;/tr%26gt;



%26lt;/table%26gt;



.table-general {



border: 1px dashed black;



}



Why does my CSS code not work in Opera like IE?windows installer internet explorer



Your designator says that table-general only belongs to the p element, not the table element.
1. You are referencing a paragraph with a class name of table-general which doesn't sound like it applies to a paragraph but rather a table. Either change the name to something more semantic to the element it references or remove the paragraph element from the CSS selector.



2. Add a color and width for the border. Without a border-width, Opera reads your code as a border of 0px. You can use a CSS shortcut to put all three attributes in one line. Here is an example:



border: 1px dashed #000000;

No comments:

Post a Comment

 
web hosting talk