Previous Message
Next Message

[css-d] Inheritance within the style sheet

Sent by John Reeve on 31 January 2002 12:12

I'm trying to find a way to build inherited relationships inside of the
style sheet. For example, i'd like to declare a style called "td.lineItem".
And then i'd like to define a style called "td.lineItem_blue" that inherits
all of the values declared in "td.lineItem". It would look like this:

	td.lineItem {
		background-color: #FFFFFF;
		font-size: 10px;
		font-weight: normal;
		color: #000000;

	td.lineItem_blue {
		/* inherit all values from 'td.lineItem' */
		color: blue;

One solution is to alter classes inline by using the 'style' parameter in
combination with 'class'. But I'd like to avoid inline declarations if I
can. The solution I am using now is to declare "td.lineItem_blue" twice.
Once to initialize its values with those in "td.lineItem" and again to add
new values. It looks like this:

	td.lineItem, td.lineItem_blue {
		/* initialize values */
		td.lineItem_blue {
			/* add additional values */

Is the latter snippet of code valid and forward-compliant? Is there an
easier way to do this?

On a side note, can anyone recommend a good reference for style sheets? Is
the O'Reilly book any good?


John Reeve


Fresh links for the web and business communities
Previous Message
Next Message

Message thread: