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

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 25 May 2012 09:55:39 -0700
Message-ID: <CAAWBYDDj6-pN=4qOgWGQxCNDaia0f4H-Gb7A0gHnBA=eCHTT2g@mail.gmail.com>
To: François REMY <fremycompany_pub@yahoo.fr>
Cc: Florian Rivoal <florianr@opera.com>, Ojan Vafai <ojan@chromium.org>, www-style@w3.org
On Fri, May 25, 2012 at 1:58 AM, François REMY
<fremycompany_pub@yahoo.fr> wrote:
>> From: Tab Atkins Jr.
>> Okay, then we're debating personal taste.  Since I obliquely pointed
>> to this thread in Twitter, I've received nearly a dozen people saying
>> they're excited, and not a single negative voice (I'm sure they're out
>> there, but I haven't heard them yet).  I also know that others within
>> the WG are cool with this (some people mentioned this syntax when I
>> first presented the modern draft at TPAC), so it's not even a "WG
>> versus authors" divide.
> It's easier to get voices to acclaim a change than to keep things the same.
> Personnaly, I dislike the proposal to use the dollar sign for variables.
> This is a PHP-only convention, and one of the reason I dislike coding in
> PHP. I know many people who dislike to use $ for variables. Beside the fact
> some poeple don't like it, this doesn't follow the established CSS
> conventions.
> Also, please keep in mind that we don't all have EN-US keyboards. On French
> keyboards, typing $ is akward. One time over three, I endup typing a ^
> instead. Having to type a $ hurts my typeflow.

I recognize that typing $ isn't easy on all keyboard layouts, since
it's not used for all currencies.  However, it's clearly a popular
glyph to use for this kind of thing.  PHP is the major source of it,
but as Jonathan and Brian said in response to you, a *lot* of other
scripting languages use it, both ones built on JS and ones used
separately.  And, of course, the ever-popular jQuery uses it by

If you don't like typing $, it's increasingly difficult to avoid it.
I suggest modifying your keyboard layout.  I do that when I'm writing
a lot of Lisp, for example - I swap my () and [] so I can type parens
without Shift.

> BTW, if you want a more important reason not to change the CSS grammar to
> allow the DOLLAR symbol, I have one:       html { $color: red; }      makes
> the text color red in IE6 and IE7.

That's an interesting point, but not an important one in my opinion.
IE6 is finally dying out.  IE7 is still quite present, but on its way
out.  Obviously, neither of them support variables.  All you have to
do is not name your variables the same as CSS properties in the
stylesheets that they receive.

On Fri, May 25, 2012 at 6:37 AM, Joshua Cranmer <Pidgeot18@verizon.net> wrote:
> A more serious issue, IMHO, is that many templating systems use $foo for
> variable substitution. If anyone wants to use CSS variables with a
> templating system generating CSS files, this can cause issues.

Among the two major CSS preprocessors, SASS uses $ (but its
maintainers insist that this shouldn't affect our decision), while
LESS uses @, and thus is irrelevant.

Among the HTML templating engines I've seen, use of naked $foo appears
to be rare - it's usually enclosed by some fancy variety of parens
like {{}} or <? ?> or the like.  I've already argued, though, that
being incompatible with a templating engine isn't a very strong
argument against.  The people adding variables to their page are the
same people choosing to use the templating engine, or at least are
closely connected to them.  They can work around the issues as they
come up.

On Fri, May 25, 2012 at 9:25 AM, Daniel Glazman
<daniel.glazman@disruptive-innovations.com> wrote:
> I also read recently that PHP is the most incoherent and sometimes
> unreadable language ever, grown in circles from multiple syntactic
> sources and having multiple solutions for features. Hum, to say the
> least.

As a frequent PHP coder, I can confirm that PHP is a horrible language
overall.  Its variable syntax is perfectly sane and regular, though.
While CSS grows in a manner similar to PHP, I think our efforts to
keep the syntax consistent and establish strong conventions have
helped a lot to avoid some of the many, many pitfalls that PHP has
fallen into.  ^_^

Received on Friday, 25 May 2012 16:57:25 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:59 UTC