[kwlug-disc] CSS: varying colours based on inheritance

John Johnson jvj at golden.net
Thu Jul 7 01:53:32 EDT 2011


On 2011-07-06 18:14, John Van Ostrand wrote:
> Here's an example
>
> ul { color: #00ff00; }
> ul ul { color: #00aa00; }
> ul ul ul { color: #007700;

And another example:
This one disassociates the tie-in to 'ul' and opens up the ability to 
tie the classes to other HTML elements.

CSS:

.level_1 {
     color: #00ff00;
     other-attributes: values;
}

.level_1 .subLevel_1 {
     color: #00aa00;
     other-attributes: values;
}

.level_1 .subLevel_1 .subLevel_2 {
     color: #007700;
     other-attributes: values;
}

But neither example addresses the original request to do things 
programmatically.
As if HTML & CSS can be considered programming languages. ;)
Ref: http://urbanoalvarez.es/blog/2009/11/18/the-programmers-hierarchy/

Thanks to JohnVanO for showing how to do this in JavaScript.

Jsqaured






More information about the kwlug-disc mailing list