magazine resources subscribe about advertising




 CD Home < Web Review <  

> Style Sheet Reference Guide's CSS FAQ

By Eric A. Meyer

How much of CSS does Netscape 3.x support?
None. Zero. Zip. Nada.
How come my styles don't work in [insert browser here]?
Although there can be many different answers for this simple question, the first thing to check is that you have correctly written your styles, and that you have a correctly-written page. In order to do this, make sure you validate both your page and its stylesheet using the W3C validators: Once you're sure that you've eliminated all HTML and CSS errors, then it makes sense to start looking for browser bugs—not before.
How can I apply styles to form elements like INPUT and SELECT in Navigator 4.x?
You can't do this correctly. It is possible to trick Navigator into grabbing styles from parent elements, but this is an exploitation of a bug in Navigator's inheritance code and should only be used as a last resort. This is especially true since the workaround can introduce even worse dislpays in other browsers.
I'm trying to get Navigator 4.x to use 'hover' styles on hyperlinks, but nothing happens. What's wrong?
The good news is that you probably aren't doing anything wrong. The bad news is that Navigator 4.x doesn't support the hover pseudo-class, so any attempts to make it work will be futile. There are rumors of Javascript workarounds, but these almost always turn out to be related to image-rollover effects.
I set styles on the BODY tag, but none of my page's text has the specified style. Why not?
In most cases, this is because you have laid your page out using tables. For a variety of reasons, table implementations in current browsers will break the CSS inheritance mechanism, so setting styles on the BODY tag is not enough (even though it really should be). Modify the selector of your BODY rule to look like this:
This will apply the styles directly to TABLE and table cell elements. Note that this will only sometimes work in Navigator, which has extra-special problems with tables and styles.
I set an ID on a table cell, and then wrote a rule for it, and Navigator 4.x is ignoring it completely. Why?
Navigator 4.x doesn't particularly like ID selectors, so the best thing to do is convert your IDs to classes and adjust your rules accordingly. Note that this may lead to other problems with the cascade, since ID selectors have a higher weight than class selectors.
How can I use CSS to enforce a specific width for the document?
To begin with, you shouldn't be doing this with Web pages—document widths are appropriate for paged media (such as printouts), but not Web browsers. If you're still determined to do this, then in theory you can set a width on the BODY element, like this:
BODY {width: 666px;}
This behavior is not well supported, however; only MacIE 4.5+, Opera 3+, and Navigator 6 will even attempt to do as you ask.
My styles look great in a Web browser, but when I print out the page, I get horribly mangled output (one line of text per page, etc.)!
If you're printing in Navigator 4.x, check to see if your styles use the line-height property. If line-height is set using points or length units (ems, pixels, inches, etc.), the pages get kafluffled.

Copyright © 2003 CMP Media LLC