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

Re: [css-variables] Using $foo as the syntax for variables

From: Pete Boere <pete@the-echoplex.net>
Date: Sat, 26 May 2012 20:09:30 +0100
Message-ID: <CAKZZz6cvcOkx=2W-6umM2S=6aQraxoOMBY4fRpkBp6e9s0cy+A@mail.gmail.com>
To: www-style@w3.org
>From the perspective of PHP (and perl or bash) scripters, dollars in CSS
would create everyday problems.

Heredocs:

print <<<CSS
<style>
p {
color: $bar;
}
</style>
CSS;

I'm not sure what is supposed to happen with CSS variables used in inline
styles, but variable interpolation when printing html attributes is very
common in PHP:

echo "<hr style='color: $foo;' />";


In favour of the existing proposal – other than not creating any more
escaping headaches – is that I like the var prefix as it compliments
variable declarations in JavaScript.

Since JavaScript is undoubtedly the most familiar (or only language
familiar to most CSS authors) the allusion is a strong point in favour, imo:

<script>
var foo = 'hello';
alert( foo );
</script>

<style>
div {
var-foo: red;
}
.mod {
color: var( foo );
}
</style>
Received on Saturday, 26 May 2012 19:09:56 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT