Re: NS 4 sniffing?

by Andrew McFarland <aamcf(at)aamcf.co.uk>

 Date:  Sun, 26 May 2002 18:00:43 +0100
 To:  <hwg-basics(at)hwg.org>
 References:  nrc ntlworld ntlworld2 ntlworld3 hilma
  todo: View Thread, Original
At 14:30 25/05/02 +0100, Hilma wrote:
<SNIP/>
>Can anyone tell em how to find out if i am in NS4 so i need the other style
>sheet (perferably not using JS else those with JS disabled will not get the
>other style sheet).

Any sort of browser sniffing is going to cause problems. There is a very 
easy way to hide CSS from Netscape 4.x

Netscape 4.x doesn't support the @import rule in CSS. Therefore, if you put 
all of your NS4 unfriendly rules in an @imported CSS NS4 won't see them :-)

Your main CSS, which should be linked to as normal, should have this:

/* Main CSS */
@import url('foo.css')

/* Netscape friendly CSS here */

And foo.css should have the Netscape 4.x unfriendly rules in it.

This works like a charm.

Andrew

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA