Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing an external style sheet 1

Status
Not open for further replies.

asrisk

MIS
Nov 27, 2003
105
GB
Hi all,

In my (limited but growing) CSS experience, I have always referenced style sheets like this:

Code:
<link rel="stylesheet" type="text/css" href="styles.css">

Recently I have seen style sheets referenced like this:

Code:
<style type="text/css"><!-- @import "styles.css"; --></style>

Which of these is favoured, and why?

Thanks,

Andy.

-------
I am not responsible for any "Sponsored Links" which may appear in my messages.
 
I use the first one.

The advantage of the second is that Netscape 4.7 is totally unable to understand it. The result being that NS4 users see the totally unstyled content of the page. This can be good, as NS4 makes such a pigs ear of interpreting anything beyond the most basic CSS that it can be better for it not to try.

Sometimes (for the same reason) you'll see a basic stylesheet (with just font & colour stuff) referenced with <link>, and an advanced one (with layout, etc.) referenced with @import.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks Chris - useful details.

Andy.

-------
I am not responsible for any "Sponsored Links" which may appear in my messages.
 
In addition the following is "meant" to be true... not sure if it still is though.

Multiple <link> stylesheets will present the user with a choice of which sheet to use. OR the document will only use the last <link>. Each stylesheet included with a <link> command (of the same media type) will over-ride previous ones.

The @import command will merge stylesheets together. It is therefore possible to build up complex stylesheets based on smaller "modular" ones.

Personally I tend to use <link> but I only really ever use 1 per document so I cannot vouch whether the above info is ACTUALLY true or not. It's just something hanging about in the darker parts of my memory.

- Web design and ranting
- Day of Defeat gaming community
"I'm making time
 
That does not seem to hold true as I have used multiple <link> commands for stylesheets (one for the layout, one for the default tags, one for the elements specific to certain pages) and it worked as expected -- all the definitions from all the stylesheets worked. Using <link rel="alternate stylesheet" ... /> will present the user with an option to choose an alternate stylesheet in browsers like Mozilla, FF and Opera.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top