hiding stylesheets from older browsers
Yesterday’s funky mishaps with multiple stylesheets made me wonder how one is supposed to hide multiple stylesheets to older browsers.
While it is possible to have alternate stylesheet with <link> tags, it doesn’t seem to work that well with two <style> tags that @import stylesheets, when in fact both @import statements are executed and used as default style.
So in the end I’m forced to use <link> tags and present Netscape 4 & co. some style that it’ll choke on. Or I could make my stylesheets @import other stylesheets. I’m not fond of russian nesting dolls when it comes to CSS, so if you know another method, there’s a comment form waiting for your wiser input.
10 responses
Michel, what’s the difference between import and the link tag? Is it an xml issue?
#1 Daynah — 2002/11/04 at 9:03
Maybe I’m misunderstanding your problem, but have you tried using comment markers? For example:
#2 Steve — 2002/11/06 at 9:11
D’oh! It didn’t show up, lets try this again… Example:
<STYLE TYPE=”text/css”>
<!–
ABCXYZ {
xxx-xxx: 123;
yyy-yyy: 456;
–>
#3 Steve — 2002/11/06 at 9:13
Daynah, @import is a CSS command that is not understood by Netscape 4 and lower browsers. This is why it’s mostly used to hide stylesheets from older browsers.
Steve, the markup I’m using is in my <head> section, it’s commented out (view source).
#4 michel v — 2002/11/06 at 9:14
D’oh! It didn’t show up… for Example:
<STYLE TYPE=”text/css”>
<!–
ABCXYZ {
xxx-xxx: 123;
yyy-yyy: 456;
}
–>
</STYLE>
#5 Steve — 2002/11/06 at 9:15
Ah I see, but you did it wrong, the comment markers go inside the style tags.
#6 Steve — 2002/11/06 at 9:18
Yeah. The comments are out of the style tags so that the styme tags really aren’t used! :P
But I tell you, it’s not a matter of comments (no need to put comments for an @import command). It’s a matter of browsers not understanding the 2 @imported stylesheets are distinct and shouldn’t be used both at once.
#7 michel v — 2002/11/06 at 9:20
Lol, well then I don’t know what to tell you.
#8 Steve — 2002/11/06 at 9:29
Hello,
there are several other ways to hide your css from old/ and not so old browsers
you can do that with the
@import rule
media attribute
some comments
attribute, child selectors
Tantek’s hack
and …too long
so here is a good place for information about that
http://pixels.pixelpark.com/~koch/hide_css_from_browsers/
and as bonus this is the way (it validate w3c) to comments style
*/–>
Apologize for my poor english (i’am from belgium)
cheers
#9 spoutnik — 2002/11/08 at 3:28
spoutnik
made a mistake in the way to comment style
<style type=”text/css”><!–/*–><![CDATA[/*><!--*/
...
/*]]>*/–></style>
must be ok this time
I hope so
#10 spoutnik — 2002/11/08 at 3:38
Your words