Forum Moderators: not2easy

Message Too Old, No Replies

CSS for IE5/Mac only

...like conditional comments for IE/Win

         

DrDoc

7:24 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A recently discovered method for hiding CSS from every browser but IE5/Mac involves an incorrect syntax for importing stylesheets. IE5/Mac sees stylesheets that are imported with no space between the @import statement and the URL, when url is omitted from the statement, like this: @import("ie51.css");

As far as I know, no other browser will load the style sheet. Of course, it doesn't validate...

SuzyUK

8:01 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Doc

one that does validate but you need reverse psychology is the commented backslash hack

This hack hides from IE/Mac so you can declare the rules you want Mac to see first in the cascade then hide the "real rules" in a commented backslash hack so everyone else will get it.

div {IE/Mac rule}

/* start hide \*/
div {what you want everyone else to see}
/* end hide */

or is there a specific conditional comment that targets IE/Mac 5.2 or 5.1 etc...only?

Any mac users out there care to be specific?

Suzy

DrDoc

8:57 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I know about the commented backslash hack... But, I'd like to use something that hides from everyone but IE/Mac :)

bakedjake

9:00 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



More details at: htHA! you silly autolinker. jdMorgan told me how to defeat you!

chambone

9:06 pm on Jan 9, 2004 (gmt 0)

10+ Year Member



Hi,
I use the @import hack as well and it does indeed validate. At least xhtml 1.0 strict, I haven't tried with other doctypes. I use it like so:

<style type="text/css">@import("css/ie5mac.css");</style>

However, I noticed some file not found entries in my error log from a IE6 user. I should probably add a / before css.

That backslash trick is handy too, especially if you use multiple stylesheets and a switcher.

DrDoc

9:08 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm, on that page it says that it validates... when, in fact, the CSS validator gets a parse error...

DrDoc

9:11 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it does indeed validate

HTML, yes... but not CSS...

chambone

9:21 pm on Jan 9, 2004 (gmt 0)

10+ Year Member



HTML, yes... but not CSS...

You're right, it doesn't. I hadn't tried it like that. I always check html with the markup validator and css with the css one. Hmm.. should you do it like that? I mean, put a link to an html file in the css validator.

SuzyUK

9:28 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmmm yes see your point...

what you want, especially as M$ are so good at covering themselves, and I believe (or try to!) they always do give us a "get out" clause, is to know which conditional comment [msdn.microsoft.com] if any could specifically target Mac versions?
e.g. 5.1 or 5.2 that way you wouldn't have to "hide" CSS with hacks you would just specifically target them as per IE's usual rules. and the CSS would still validate

Suzy

DrDoc

9:29 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...if conditional comments even work in IE/Mac [webmasterworld.com], that is. I have reason to believe it doesn't, but I'd like to know for sure.

DrDoc

4:45 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Playing around with getting the @import rule to validate, while still making other browsers ignore the style sheet I tried this:

<style type="text/css">
@import["stylesheet.css"]
</style>

And, truly, all browsers I've tested this in, completely ignore the @import rule. So far, I've tested in

IE 5/Win
IE 5.5/Win
IE 6/Win
Opera 7/Win
Mozilla 1.5/Win
FireBird 0.7/Win
But, what about other browsers? Mainly, what about IE/Mac? How does IE/Mac handle this?

chambone

10:26 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



This is ignored by IE5.2 mac. Safari and Mozilla ignore it as well.

DrDoc

10:40 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's a bummer...
An import rule that hides data from all browsers. LOL How unfortunate ;)

More to come. There must be something out there that validates and is recognized by IE/Mac only :)


Is it ignored without the quotes as well?

<style type="text/css">
@import[stylesheet.css]
</style>

DrDoc

10:51 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Other possibilities:

@import[url("stylesheet.css")]
@import¦ url("stylesheet.css")
@import¦ "stylesheet.css"
@import¦"stylesheet.css"
@import `stylesheet.css`

chambone

1:36 pm on Jan 11, 2004 (gmt 0)

10+ Year Member



I tried all of your suggestions, but unfortunately the only one IE picks up is

<style type="text/css">@import("stylesheet.css");</style>

It was tested through apache on OS X. Can't say for OS 9, but I doubt it will make a difference. Too bad.

But let's be grateful that we still have the commented backslash hack :)