Re: author-defined color aliases

I just joined this mailing list to suggest such an idea, but I see it
has already been mentioned.

Personally, I would find it really useful to be able to define names. 
If you require that aliases be placed before they are used, or all the
way at the top, then they will not require preprocessing, since they
will have already been encountered.  One way to make this easier to
implement would be to require some character (maybe a dollar-sign?)
before an alias or require it to be inside some type of brackets
(probably not angle brackets, since that would either screw up X(HT)ML
parsing or require a <![CDATA[ before every embedded stylesheet, but
maybe square brackets...).

JavaScript and server-side generation are, in my opinion, bad answers
to this feature request.  JavaScript is constantly used to patch up
little holes like this, where web developers really want a feature but
it doesn't exist.  It's also a bit absurd to have a browser fire up a
scripting engine just to fill in the blanks in a stylesheet. 
Server-side generation also has its place, but, again, it's absurd to
serve all your pages dynamically when all you need is to fill in a
color name in several places.

Another, more general idea would be to add a "virtual class" type of
thing.  Let's say you want h1 through h6 to be bold red (let's call it
"important", no relation to ! important), and h1 and blockqoutes to be
centered with one inch margins and a 2px solid gray border (let's call
it "boxed").

$important { font-weight: bold; color: red; }
$boxed { text-align: center; border: 2px solid gray; }

h1 { virtual-class: important, boxed; font-size: 1.50em }
h2 { virtual-class: important; font-size: 1.45em }
h3 { virtual-class: important; font-size: 1.40em }
h4 { virtual-class: important; font-size: 1.35em }
h5 { virtual-class: important; font-size: 1.30em }
h6 { virtual-class: important; font-size: 1.25em }
blockquote { virtual-class: boxed }

Now, you might say that this is dumb, since you could just say

h1, h2, h3, h4, h5, h6 { font-weight: bold; color: red }
h1, blockquote { text-align: center; border: 2px solid gray; }

// and then all the h1..h6 font sizes

...but adding either virtual classes or aliases would make the
stylesheets more readable, and more indicative of what you are trying
to do.  It's like the difference between "old" HTML, where someone
trying to analyze your page would have to figure out what's content
and what's layout, and XHTML, where everything is defined: rather than
looking all over the stylesheet to find all the rules applied to h1,
you could just look at it and see "virtual-class: important, boxed"
and know, generally, what it will look like.

On second thought, this "virtual class" thing is probably overkill. 
Still, it's better than scripting.  There is definitely a need,
however, for something in CSS that can "remember" either values or
entire property-value pairs and apply them later.

Criticism is welcome...

--Thomas Tuttle

Received on Friday, 14 May 2004 19:27:23 UTC