W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Set a CSS property to the value of another CSS property

From: Brice PARENT <brice@websailors.fr>
Date: Mon, 16 Jan 2012 11:04:56 +0100
Message-ID: <4F13F648.6050002@websailors.fr>
To: www-style@w3.org
It would be really nice to have the ability to set a property's value
using a pointer to another property's value. To be more explicit, 3
examples :

..model{color:red; border:2px solid blue;}

/* simple pointer : */
..example1{color: as(.model);}
/* The text color is red (as found in .model{color:red;}) */

/* complete pointers */
..example2{margin: as(.model?border-width); background-color:
/* The margin is 2px on all sides (as found in
..model{border-width:2px;}), and the background color is blue (as found
in .model{border-color:blue}) */

/* inner pointer */
..example3{color:grey; border: 1px dashed as(?color);}
/* The border-color is grey (as found in .example3{color:grey;}) */

"as()" and "?" could of course be replaced by any other
keywords/keychars in the spec.
It would help a lot to manage big or multiple css files, and would
probably allow many other things.
If the model property doesn't exist, the property wouldn't do anything.
Of course, any property's value could be used for this (not only
dimensions and colors).

Possible problems :
- it would be harder to define the properties, as some of them would
have to wait for all the css to be computed before being set.
- Infinite loops could be created, but the property could be removed
immediately when a loop is found.

What do you think about it?

Received on Monday, 16 January 2012 14:07:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:09 UTC