RE: Proposal: inheritance of styles -in the stylesheet itself-

Brent Boyer wrote:
>
> What I propose for CSS is that it allow inheritance of styles -on the
> stylesheet itself-.  (I am well aware of how styles inherit down the
> document structure hierarchy; that is a separate issue; the discussion
>  below will also touch on it.)
>
> Specificly, you should be able to define a parent style, and have child
> styles of that parent inherit all its properties unless explicitly
> overriden. The mechanism that I am proposing is simply that which is
>  done in Object Oriented programming.

I have also noted the lack of such a mechanism, and see its utility. I like
your idea in general --though I'm prejudiced myself, coming from an O-O
background. Still, I think that there may be a danger in taking too
object-oriented an approach to what is really a flat format; after all,
while it may have "variables," there are no methods (with the possible
exception of the pseudo-element selectors).


>
> I propose that every style be allowed to extend from from one parent
>  (single inheritance, just as in Java).  So, the above could be
>  condensed to:
>
> 	.normalText {
> 		text-align: left;
> 		text-decoration: none;
> 		vertical-align: baseline;
>
> 		font-family: "Times New Roman", "Times", serif;
> 		font-size: 1em;
> 		font-style: normal;
> 		font-weight: normal;
>
> 		color: inherit;
> 		background-color: inherit;
> 	}
>
> 	.large1Text extends normalText {
> 		font-size: 1.2em;
> 	}
>
> 	.large2Text extends normalText {
> 		font-size: 1.44em;
> 	}
>
> Unless I have missed something in the CSS spec (or a new proposal),
>  there is currently no way to achieve the above.

No offense intended, but the above seems syntactically mismatched with CSS,
and slightly limited in its scope. Why limit the relationship to single
inheritance? If for the purpose of preventing conflicting attributes, CSS
already deals with that by using the later definition (or one marked
!important, of course) (i.e. .normalText{ text-align: left; text-align:
right;} has the value "text-align='right'". Also, ".large1Text extends
normalText" seems like it should be ".large1Text extends .normalText", (just
to be picayune)...

I think a more flexible mechanism, with a more CSS syntax, would be
something like:

	.normalFont {
		font-family: "Times New Roman", "Times", serif;
		font-size: 1em;
		font-style: normal;
		font-weight: normal;

		color: blue;
	}

	.normalText {
		text-align: left;
		text-decoration: none;
		vertical-align: baseline;

		color: inherit;
		background-color: inherit;
	}

	.large1Text {
		@inherit: .normalFont;
		@inherit: .normalText;
		font-size: 1.2em;
	}

	.large2Text {
		@inherit: .normalFont !important;
		@inherit: .normalText;
		font-size: 1.44em;
	}

... where ".large1Text", ".large2Text" have all the properties of
".normalFont" and ".normalText", with the exception that ".large2Text" would
take the "important" value of blue for "color," rather than inheriting.

But, like I said, the basic idea seems sound, regardless of the syntax.

-Doug

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.404 / Virus Database: 228 - Release Date: 10/15/2002

Received on Monday, 21 October 2002 02:09:36 UTC