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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Style Sheets

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
I know I can use multiple style sheets per page, but am having trouble understand how.

I link both sheets before the head tag. I have one sheet I want for my header, and one sheet to apply to my content. If you can give any tips that'd be great. Thanks.

/styles.css
/content.css
 
You need to link them both, normally,

Code:
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<LINK REL=StyleSheet HREF="content.css" TYPE="text/css" MEDIA=screen>

And then just use classes form either one.

Code:
<div class="classinstylecss">...</div>
<div class "classincontentcss">...</div>

The problem may arise when the same class is present in both sheets. The lower style sheet, in this case content.css, will take precedence. In which case any object with a class in both sheets will use the stylings defined in content.css

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
The lower style sheet, in this case content.css, will take precedence.

Assuming all the rules are of equal specificity, yes. But if a rule in the first CSS was more specific, or used !important, then it would still "win".

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
As for your specific code (the link you gave us in your post), you have the whole header part duplicated. That will surely cause browser to choke, as only one doctype, html, head and title are allowed per page. Make sure you only have one set of those and all the stylesheets loaded inside that one head. Then it should work ok.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top