Nothing but .net

CSS: use the @import or don't use it?

When using CSS, you can link the stylesheet to your HTML using the 'link' tag (pure HTML) or you can use the @import directive.
Which of these 2 is the best, one might think? Well, the answer can be determined by the browsers you are targetting with your site. The @import is currently understood by every modern browser, however, if your visitors (or at least some...) are still using Netscape Navigator 4, you are better of using @import.

Why is that? Well, NN4 does a terrible job rendering CSS, even up to a point where it makes CSS enabled webpages unreadable. However, it doesn't understand the @import directive and thus ignores CSS. This way, you can make this 'error' an advantage: it will render your page, though it will not look good, it will at least be readable!

Posted on Wednesday, 18 July 2007 21:13 by gill  |  Comments (2)
Filed under:   Tips and Tricks | Design

Related posts

Comments

July 28. 2007 01:20

Adrian Johnson

The other problem with the @import directive is that it has been known to crash Visual Studio 2005 when using it. I had been developing a web site using VS, and noticed certain web sites were crashing when they were being developed. A discussion with Microsoft resulted in the advice to remove the @import directive. Not really a show-stopper - just thought you ought to be aware.

Adrian Johnson

August 4. 2007 16:22

kevin


I'm saying a prayer for you that you really don't have to still support NS4 ;)

kevin

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 7. 2009 04:40