Re: css constants

----- Original Message ----- 
From: "fantasai" <>
To: <>
Sent: Monday, August 27, 2007 11:58 AM
Subject: Re: css constants

> L. David Baron wrote:
>> On Monday 2007-08-27 12:18 -0500, Devi Web Development wrote:
>>> Please forgive me if this has been discussed extensively before, but a 
>>> lot
>>> of people (see below) have talked about it at various points and I 
>>> haven't
>>> seen it in any draft; why not have an @variable or @constant that would 
>>> set
>>> a constant that could be used as a value?
>> There are many different ways constants could be used.  A proposal
>> that would support all of them would be difficult to specify and
>> difficult to implement.
>> It might help move this idea forward if somebody compiled a list of
>> the major use cases for constants and their relative importance.
>> (Creating additional named colors is a common one given in examples,
>> but I suspect there are others.)  Knowing what the use cases are is
>> needed to design such a feature properly.
>> A wiki page would be a good place to do this.  Do we (the CSS
>> working group) have a publicly editable wiki yet?
> Created
> which should now be publicly editable.

BTW: Wiki at does not allow to register  - does not 
passwords back.

We use following implementation (in h-smile core: htmlayout/sciter):

1. const @-rule - const declaration:

@const name: value(s);

   name is a symbolic name (nmtoken?);
   value(s) - single value or sequence of values.

@const  THEME-BORDER-WIDTH:  1px 1px 1px 1px;
@const  THEME-BACKGROUND-COLOR:  orange;
@const  THEME-DEFAULT-FONT:  12pt arial, helvetica, sans-serif;

2. const insertion point is marked by '@' symbol immediately followed by the 
name of
the constant:

#something {
   border-width: @THEME-BORDER-WIDTH;
   left-boder: @THEME-BORDER-WIDTH solid black;

3. Insertion of non-existent const is not an error.


@const in our implementation are immutable things - they behave as macro
preprocessor definitions in C/C++.
List of defined @const(ants)  is read-only accessible  in script. That
allows to pass parameters defined in CSS to scripts.
In our case event handlers of DOM elements are assignable by CSS by
prototype:EventHandlerNameInScript CSS attribyte so such parametrization
makes additional sense.


I also have a feature named style-set that allows to assign blocks of styles
to DOM subtrees in all-or-none fashion. Very useful for components in AJAX 
But this is different story. I can expalin when wiki will be available and 
if needed.

All this works  in real life about year so far and I cannot recall any 
problems with
syntax and overall logic.

Andrew Fedoniouk.

Received on Tuesday, 28 August 2007 00:53:55 UTC