Re: Proposal/idea: variables in CSS

Larry Israel:
>
> In some future incarnation of CSS (maybe CSS4?), I would like to be able
> to set some variables, the contents of which would be replicated in all
> instances of the variable within that style sheet. For example:

IIRC I started here with the same wish, but a different idea how to
implement ("@var" or "var()").

Often there's no need for it, when the cascade is used properly. I would
need it to simplier change colors and widths, but a good CSS editor should
provide a mechanism for variables itself (is there any such?).

> var sans1=("gill sans","trebuchet ms",verdana,helvetica,arial,sans-serif)
> h1 {font-family: sans1; ...

For fonts the @font-face rule already exists, but is AFAIK implemented
nowhere:

@font-face {
    font-family: sans-serif;
    src: local("gill sans"), local("trebuchet ms"),
         local("verdana"), local("helvetica"), local("arial");
}
h1 {font-family: sans-serif; ...

<http://www.w3.org/TR/CSS2/fonts.html#font-descriptions>

> I don't know what the best syntax for this would be. var=...

That won't work, due to CSS grammar restrictions, AFAIK. Some @-rule is
preferable.

> might be confused with the XHTML2 element with the same name,

var is a pretty old element in HTML.

> But I do know that everyone is repeating many definitions in their style
> sheets, especially font "sets."

Yes, but in many cases it's just bad style.

> Variables in (X)HTML could serve as an
> *easy* way to incorporate repeated bits of text

That's a whole different thing, off topic on this list, and could already be
done using custom DTDs and entities.

Christoph Päper

Received on Friday, 17 January 2003 07:56:31 UTC