Previous Message
Next Message

stylesheet variables

Sent by Chad A Gard on 28 March 2004 02:02


Since folks are talking about pet peeves with CSS, perhaps it's a good 
time to bring up a thought I have often had as an addition.  Perhaps 
it's already being considered, as I've not really read any of the CSS3 
recommendations yet...

But, does anyone else think it would be nice to have variables in 
stylesheets?  For example, in a complex site with multiple style sheets 
with lots of selectors and rules, there are often only a handful off 
colors that are used, but they're used in lots of places.  One color 
could be used for a header background, visited links in a menu, and the 
borders on images in a #productInfo div (OK, probably an unrealistic 
conglomeration, but you get the idea).  Another color could be used for 
links, h1's and h3's in the content area, as well as the bullets on 
ul's.

So, as it is, one has to specify the color in multiple places.  Now, 
the client (or you or whomever) decides that instead of using the puce 
color for the logo for the links, h1's, h3's, and ul bullets, he wants 
a pretty tangerine color that hilights  the color of his dog's eyes in 
the bio section.

So, now, you have to search-and-replace throughout your stylesheets on 
that color.  Not usually a big deal, unless you happen to have more 
than one logical collection of things that are the same color.

What I'd like to see is the ability to do something like this:

$logocolor = #c3c;
$dullcolor = #000;
$impactcolor = #f00;
$coolcolor = #00f;




body {	color: $dullcolor}
a {		color: $coolcolor;
		border: 1px solid $logocolor;
		}

a:hover {	color: $impactcolor;
		border: 1px solid $coolcolor;
		}


etc. etc.
presumably variables could be used for any property value, or perhaps 
even any string of text.  Colors are just what come to mind to me most 
frequently.  Presumably they fit into the DOM such that a variable 
defined anywhere would be global across all stylesheets, unless it had 
been declared in a media-specific stylesheet.

Anyone else ever have thoughts along these lines?  Is there a way to 
make such suggestions to the W3C without being a member of a member 
organization or joining the [EMAIL-REMOVED] list, which would seem to 
only rarely be of interest to me?


Chad A Gard
http://www.percussionadvocates.com/chad


______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: