[thelist] Browser specific stylesheets

Timothy J. Luoma luomat at peak.org
Sun Nov 10 09:18:00 CST 2002


On Sun, 10 Nov 2002 14:55:39 -0000, Dave Stevens <dave at stemfiction.com> wrote:

> I have a page that uses absolute positioning to place one div on top of
> several others. However, as the site is centred on the page, I'm using
> (window.width/2) to position the content div. (Thanks to someone on this
> list :))

So I'm guessing that you are using javascript?


> Problem is, Netscape and Opera are not liking it, and placing the div
> incorrectly. So what I'd like to do is have a separate stylesheet for
> these
> browsers.
>
> Would anyone like to tell me the best way of doing this?

Would you like to tell us the URL ;-?

That way I would be able to find answers to a half-dozen different
questions that are left unanswered:

1) does the HTML validate?
2) does the CSS validate?
3) are you in standards or quirks mode?
4) what version(s) of Opera have you tried?
5) what version(s) of Netscape have you tried?
6) do Opera and Netscape both fail the same way, or different ways?
+ bonus question
7) do you want one separate style sheet for Opera and another one for
Netscape, or one separate style sheet for both?


Basically your options are to either rely on either 1) CSS parsing quirks
or 2) UA sniffing.

Both have drawbacks.

1) If you are using recent Netscapes or Mozilla, it'll be hard to find CSS
parsing quirks. Opera 6 has two CSS parsing bugs, one of which only works
if you are using XHTML but not serving (MIME type) as XHTML (i.e.
application/xhtml).  Future versions of Opera might fix the CSS parsing bug
but NOT fix the scripting problem you are using, so relying on CSS parsing
quirks is a bad idea here.

2) Since you are already using scripting you could use javascript UA
sniffing or even server-side UA sniffing I guess.  Opera's UA string always
has the word "Opera" in it (although WHERE in the UA string is another
question, depending on build and how the user has the ID set).  Mozilla has
'gecko' in the UA string.... you're on your own for older Netscape builds
though, I can't help there.

TjL




--
http://tntluoma.com





More information about the thelist mailing list