Hello.
What's the main difference between importing CSS or linking it?
The size of the html page?
Thank you.
| SitePoint Sponsor |



Hello.
What's the main difference between importing CSS or linking it?
The size of the html page?
Thank you.

what do you mean by embedded? just placing it in <style>-tags or using the @import feature?
myself I prefer using the @import feature, for example:I've heard this should work better than using a <link>-tag in some cases...Code:<style type="text/css"> <!-- @import url(./inc/stylesheet.css); --> </style>



Yes! Embebbed is:But I always used the a link to external css.Code:@import url(./inc/stylesheet.css);
And I would like to know which should use and why?
[img]images/smilies/smile.gif[/img]
The link is supported by all browsers, whereas import isn't. Importing it and leaving out link means your stylings can be only viewed by browsers with CSS support. Browsers that won't see it are:
* Netscape 4.x
* Win IE 3
* Win IE 4 (not 4.72)
* Mac IE 4.01
* Mac IE 4.5
* Konqueror 2.1.2
* Win Amaya 5.1
Using both ensures everyone can view your webpage, though it may not look right if CSS isn't supported.
Linking to an external .css file allows the browser to cache it, so other pages can use it without having to load it everytime.
Actually, IE4 can read @import unfortunately![]()


So what are the benefits of @import over link? The fact that old browsers won't screw up your css?
@import was meant to easily include other stylesheets from within a CSS file. Think of it as SSI or php's include() function, but for CSS files. It also has the added benefit of being hidden from Netscape 4.Originally Posted by tempus


Does anyone have any other information of links about the benefits of one over the other?





Like Vinnie said.
A frequently used trick is to link to a 'simple' stylesheet for NN4 and import the 'full' stylesheet for newer browsers.
Rik
English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac


but what about the problem of browsers not caching imported CSS files?
Bookmarks