W3C home > Mailing lists > Public > www-style@w3.org > July 2015

Re: [css-variables] feedback

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 13 Jul 2015 10:26:57 -0700
Message-ID: <CAAWBYDCn0JwqMAr+VofhuxOET=-7yWAr4M5njs3SsCZ-dfiAyQ@mail.gmail.com>
To: raees@thewebsmith.co
Cc: "www-style@w3.org" <www-style@w3.org>
On Sat, Jul 11, 2015 at 5:32 PM,  <raees@thewebsmith.co> wrote:
> Is there a particular reason to prefer ‘--’ over ‘$’ for declaring
> variables? I mean,
>
> $color-headings: #444;
> h1{
>   color: var($color-headings);
> }
>
> still looks better than
>
> --color-headings: #444;
> h1 {
>   color: var(--color-headings);
> }

Custom properties are properties, so they have to go in a style rule, like:

```
html {
  --color-headings: #444;
}
h1 {
  color: var(--color-headings);
}
```

Otherwise, no *strong* reason to prefer one over the other.  $ was
suggested several times during development, but we ultimately rejected
it for a few reasons:

1. $ is used by lots of preprocessors for variables already, and
they're *global* vars in those preprocessors. Stomping on their syntax
with something slightly different is rude and confusing.
1a. If we ever do use $, we'll probably use it in a way similar to
preprocessors (for example, as mixin arguments - lexically-scoped
variables).
2. Property names starting with dashes are already familiar from
vendor prefixing, so a double-dash fits in with that while still
claiming a pristine syntax space.
3. Aesthetics is a personal choice and opinions differ?

~TJ
Received on Monday, 13 July 2015 17:27:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:18 UTC