Forum Moderators: not2easy

Message Too Old, No Replies

Can i place more than one link to separate CSS files on a page?

I have 3 links to separate css files. Please help:)

         

frenzy77

6:43 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Hi guys:)

I was wondering, is it ok to have 3 separate css files in each webpage for my entire site?

>>In other words, i have 31 pages and in every page i have the following setup on each and every webpage on my site.

For example:
*All webpages have:

<html>
<head>

etc...

<link rel="stylesheet" type="text/css" href="indent.css" />
<link rel="stylesheet" type="text/css" href="xyz.css" />
<link rel="stylesheet" type="text/css" href="abc.css" />

</head>

<body>

etc........

</body>
</html>

Is it ok to do this? All my pages validate as xhtml 1.0

Well...Thanks for your help guys:)

frenzy77

bedlam

7:58 am on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it ok to do this? All my pages validate as xhtml 1.0

Seems as though you already have the answer to your question...

:^)

More reading on the subject can be found here [w3.org] and also here [w3.org].

Using multiple link elements to link to multiple stylesheets for the same media is not technically the correct use of <link ... > - though it's pretty common to use it in exactly this way, and it's not easy to see how it could be harmful.

If you wanted to very strictly follow the spec, you could use multiple instances [w3.org] of '@import' [w3.org]', either in the <head> of your html document, or in your principal stylesheet itself, either this way (multiple calls in the document <head>):

HTML:

<style type="text/css">
@import url(path/to/stylesheet.css);
@import url(path/to/additional.css);

</style>

Or this way (one call in document <head>, with multiple '@import' in the main stylesheet):

HTML:

<style type="text/css">
@import url(path/to/main/stylesheet.css);
</style>

CSS File:

@import url(path/to/additional/1.css);
@import url(path/to/additional/2.css);
@import url(path/to/additional/3.css);

Note, when using @import, that a) some older browsers do not understand this syntax at all (this can be good or bad [google.com]), and that there are minor inconsistencies in how the permissible @import syntaxes outlined in the spec are actually understood by different browsers.

-B

frenzy77

9:04 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Thanks for your help bedlam:)
I appreciate your help.

So if i place the links:

<link rel="stylesheet" type="text/css" href="indent.css" />
<link rel="stylesheet" type="text/css" href="xyz.css" />
<link rel="stylesheet" type="text/css" href="abc.css" />

Will my pages display ok?

I read through some of the info you linked to, but i really don't want to use the @import for anything.

I'm really not that css savvy so i'd just like to use
my CSS example above.

Well, back to my original question. Can i do this and will it display correctly online? It shows up fine on my pc. And it is validated.

>>Also, if i add more css files, can i just list another
<link rel="stylesheet" type="text/css" href="anotherfile.css" /> for another css file on the page?

Well, thanks again for your help bedlam:)
I really do appreciate your help:)

Thanks again.

frenzy77

Span

9:08 pm on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, back to my original question. Can i do this and will it display correctly online?

Yes.

g1smd

10:28 am on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I always use @import instead of link.

This completely hides the CSS from Netscape4, so that those users get completely unstyled, but very fast loading, content.