I have to agree about using body class instead of id.
Here's what I'm using on one page
body class="sub3 sub3sub1 sub3sub1sub4 asub3sub1sub4"

This set of classes match with a set of id's in a nested list that is used
for navigation. This has allowed me to open, close, change background
colors, add icons to show that a parent list is open for children, etc. 

You can use multiple classes but multiple id's in a tag can create problems.

For more info on this, I sent the entire css sheet to this mailing list a
couple months ago, it's probably in the archive under "when navigation lists
go bad" or some silly name like that.

Ted


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ben Curtis
Sent: Tuesday, July 19, 2005 10:23 AM
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] Body tag background color changes


On Jul 18, 2005, at 7:16 PM, Bert Doorn wrote:

>> Just wondering whether there was a way to include different body
>> background colors (for different pages) within the same css file.
>> For example #fff for page1.html, #ffc for page2.html etc.
>
> If every page has to have a different background colour, you could  
> put an ID on the body element, then in your css:
...
> If there's a few different backgrounds but they are used on a  
> number of pages, use a class instead of id.


This is a good habit, IMO, although technically the body tag is  
unique on the page and so many pages on the site can have a body tag  
with the same id -- IDs need only be unique per document. There are  
two reasons it's still useful (AFAICS) to make body IDs unique on the  
site, and classes non-unique:

1. You may be coding in XHTML, which may give you the ability in the  
future to do something entirely wacky like dump every page in your  
site into a single XML file. Then you'd want your XPath query to be  
able to home right in on a single body element.

2. Class attributes are a space-delimited list, allowing you to stack  
up the categories the body belongs to. I use this technique to define  
a range of layout types, which may be content- or section-specific,  
like so:

     <body id="pageBioPubIntphoto" class="sectionBio sectionPub  
layoutText">

The "page___" and "section___" identifiers are derived directly from  
the path, and the "layoutText" class in this case sets black text on  
white background (the "layoutPic" is mostly pictures, with a black  
background and subordinated grayish text).


With this technique, you can do more than change the background per  
page, section, or layout type. You can also, for example, set  
specific dynamic submenus to appear or hide, or layouts with the same  
IDs can be radically shifted.

-- 

     Ben Curtis : webwright
     bivia : a personal web studio
     http://www.bivia.com
     v: (818) 507-6613




******************************************************
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
******************************************************
******************************************************
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
******************************************************

Reply via email to