[thelist] CSS: question about @import

Means, Eric D eric.d.means at boeing.com
Thu Jul 25 14:38:01 CDT 2002

>  -----Original Message-----
> From: 	Chris W. Parker [mailto:cparker at swatgear.com]
> Sent:	Thursday, July 25, 2002 2:20 PM
> To:	thelist at lists.evolt.org
> Subject:	[thelist] CSS: question about @import
> hi.
> as far as i know it's recommended to use the @import command to hide
> advanced css from older browsers, i.e. nn4.x.
> i haven't heard anything about WHY i need to hide it from older
> browsers. i'm guessing that the older browser could get even more
> screwed up when it comes across advanced css. if this is not the case,
> won't the older browser(s) just skip over the css it does not
> understand?

Sadly, no.  Ideally it/they would; however, certain browsers (NS4 is the
most egregious offender) *claim* to implement a given CSS directive, but do
so either incorrectly, incompletely, or baggily.  Worse yet is that NS4 uses
Javascript to simulate CSS (instead of actually understanding CSS), and so
any bugs in its CSS implementation tend to crash the browser or have other
serious effects.

Even in cases where the browser *does* correctly ignore the unknown CSS it
can cause problems, however.  For instance, Internet Explorer 6 for Windows
doesn't understand position: fixed.  If you have position: fixed in your
stylesheet, IE6 will treat it as if it is the default (position: relative).
This causes problems because inevitably the "fixed" element ends up
somewhere the designer never intended it to be.  In this case the only
option is to somehow hide the "position: fixed" from IE6 and show it
"position: absolute" instead, while still serving position: fixed to UAs
which can understand it (like Mozilla).

> also, when you import an advanced stylesheet, does it override
> everything in the primitive stylesheet? or does it just add-on to it?

It overrides according to the normal inheritance rules.  That is, later
declarations override earlier ones (simplistic but mostly true).

> in conclusion, please point out WHY i need to seperate the two, or why
> it doesn't matter. (i.e. i can stick everything in one css file and let
> the browser deal with it.)

Well, you can, but NS4 in particular will look like crap, crash, and/or be
completely unusable.  Various incarnations of IE (4, 5, 5.5) may also be
unusable depending on which particular peccadilloes you run into.

If you use browser-hiding tricks you can eliminate a lot of that, but I
personally find it easier to use server-side sniffing to serve specific
troublesome UAs (NN4, IE before 5.5) with specific stylesheets, and then
have one mostly-standard stylesheet for the rest.

More information about the thelist mailing list