[thelist] Multiple Templates vs Multiple Style Sheets

Chris Heilmann lists at onlinetools.org
Tue Mar 15 10:30:19 CST 2005

>> Is there a way to code the differences without resorting to 20 million
>> different templates or style
>> sheets -- while being able to update the navigation rather easily?
> Give the <body> of each page a class, depending on what section it is
> in.  <body class="domaine"> and so forth.
> Then in the (one!) stylesheet you set the submenus visible or invisible
> depending on whether the ID of the submenu matched the class of the
> body
> <div id="navigation">
> 	<div id="shopmenu">
> 		<div>submenu blah blah blah</div>
> 	</div>
> 	<div id="domainemenu">
> 		Domaine
> 		<div>submenu blah blah blah</div>
> 	</div>
> </div>
> #navigation div div {display: none;}
> body.shop #shopmenu div {display: block;}
> body.domaine #domainemenu div {display: block;}
> ... or some variation thereof.
> One template.  One stylesheet.  All you change is the class of <body>.

This only applies to users of browsers with your style sheet enabled. Just
because you don't see things they are not gone. Other visitors might get a
menu they don't need and just confuses them. In the worst case they have
to tab through a lot of links or hear them.

The above trick of a class on the body is great for colour schemes and
positioning, but should not be abused for a problem that clearly is a
structural issue, not a visual one.

Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/

More information about the thelist mailing list