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
******************************************************

Reply via email to