Re: [Css Variables] Variable Declaration Blocks

I've been watching the CSS variables proposal with quite a bit of  
interest, since it would be extremely helpful for what I'm doing. I  
work on Adium ( a popular open source instant messaging  
program, which uses HTML/CSS/JS for displaying messages. Currently  
this works by having message style authors provide HTML templates with  
special keywords; when a message is sent or received, the template is  
copied, the keywords filled in with the current values, and the  
resulting html string is sent to WebKit using the Objective-C DOM  
interface (createContextualFragment specifically). You can see  
examples of message styles created by the community here:

In a number of cases, the keywords in question refer to persistent  
attributes of a conversation such as the url of an icon representing  
the person you're talking to, or their name, rather than per-message  
attributes like the exact text sent. When these persistent attributes  
change, Adium has to traverse the whole DOM looking for places where  
they were used and updating to the new value, which is definitely less  
than ideal. CSS variables would make this completely trivial, as well  
as significantly faster. Instead of something like <div  
class="message"><img src="%%userIcon%%">%%displayName%%%%message%%</ 
div> we would have <div class="message %%senderID%%">%%message%%</div>  
and use content() and background-image with variables to insert the  
persistent name and icon. Updating when the name or icon changed would  
then be a simple matter of setting a new value via the CSSOM.

Tim Hatcher, the developer of, has expressed  
interest as well for very similar reasons.

I realize this may be a bit out of scope for CSS's intended uses, but  
I think the use I've described would very likely have parallels in  
many web applications (gmail seems like an obvious one, given its  
similarities to a chat program).

								David Smith

On Oct 1, 2008, at 9:46 AM, Andrew Fedoniouk wrote:

> Why would people need "CSS variables" at all?
> We've got a lot of discussion around them but I am failing to
> see the forest behind those trees.
> Could anyone clearly explain why "CSS variables" there at all:
> 1) What problems they are trying to solve, etc.?
> 2) Why they are variables and not constants?
> 3) Are there any requests from community for exactly variables?
> Thanks in advance.
> -- 
> Andrew Fedoniouk.

Received on Thursday, 2 October 2008 02:08:54 UTC