css constants

liunx

Guest
I want to be able to do something like this...

vvlColor = rgb(255,223,191)
medColor = rgb(255,128,0)

p {color:medColor;}
ol {color:vvlColor;}

In other words I want to be able to use what we would call 'constants' in a programming language.

Other than using php (or similar) I gather there is no way to do this? Correct?

If so, why on earth wasn't this included when CSS was created?Because there's no great need? In most cases, such as your example, it would be superfluous and in others it's handled with more versatility by classes.Originally posted by ray326
Because there's no great need?

My example was small. If my page has many divs, ids, tags, etc. that all use a certain color, and I need to change the color, it would be a great help.

I supposed I can do this by being clever about classes and inheritance, but that's much more work, as I see it.No difference at all. If they all have the same special color, they all have the same class. If they all have the same (not so special) color then they're done with one selector in the sheet. Either way it's one selector that fixes you up for the whole enchilada.

.red { color: #f00; }

div, #anId, p, h1, td { color: #f00; }

No more work.Actually, you can do this in XHTML by creating your own entities. And for external style sheets you just need to use a script. With Perl it is way easy.
 
Back
Top