Live data from Hacker News

CSS Variables in Firefox 31 – new syntax

jan.rs

11–20 of 54 posts

Re: CSS Variables in Firefox 31 – new syntax

#12
post #3

Earlier quoted context omitted.

Yeah, obviously they need to avoid conflicts but surely they could have found a single character to use as a prefix instead of "--", like "$" or "@". The "var()" function is just.. redundant. Or maybe I'm missing something?

Here's the discussion where they changed from "var-" to "--": http://lists.w3.org/Archives/Public/www-style/2014Mar/0261.h... And later on the justification for not using $ or @: http://lists.w3.org/Archives/Public/www-style/2014Mar/0400.h... There's also the issue that this needs to be backwards compatible with parsers that don't support the syntax, and apparently because the variables cascade that makes it harder s…

where is the discussion for using `var()` ?

The rationale for the "--" sigil matches what I'd expected, but I don't understand: why not just `name: --value` ?

Re: CSS Variables in Firefox 31 – new syntax

#14

Can anyone think of a use case for this beyond what a precompiler (Sass, Less, Stylus) can do?

Because precompilers are sort of a disruption of the point of CSS to begin with. I know, I know, a lot of people use them, but using style sheets that require compilation pretty much defeats the purpose of separation.

Re: CSS Variables in Firefox 31 – new syntax

#15
These are not like SASS variables. I think calling this variables is causing unnecessary confusion.

This feature adds custom properties. CSS had custom vendor properties like `-webkit-foo`, and now you can have your own properties with vendor == "", so it's `--foo`.

Re: CSS Variables in Firefox 31 – new syntax

#16
post #9

So in this article, the author says this is not supported on chrome. But in this stack question [1], chrome is clearly using it. Is the only difference the author is discussing that now firefox uses/supports "--" instead of "var-"? [1] http://stackoverflow.com/questions/18466569/enable-experimen...

It was removed from Chrome in February. https://groups.google.com/a/chromium.org/forum/#!topic/blink...

Re: CSS Variables in Firefox 31 – new syntax

#17
post #9

So in this article, the author says this is not supported on chrome. But in this stack question [1], chrome is clearly using it. Is the only difference the author is discussing that now firefox uses/supports "--" instead of "var-"? [1] http://stackoverflow.com/questions/18466569/enable-experimen...

CSS variables were recently removed from Chrome: http://stackoverflow.com/a/23518831/349353

Re: CSS Variables in Firefox 31 – new syntax

#18
post #9

So in this article, the author says this is not supported on chrome. But in this stack question [1], chrome is clearly using it. Is the only difference the author is discussing that now firefox uses/supports "--" instead of "var-"? [1] http://stackoverflow.com/questions/18466569/enable-experimen...

CSS variables were recently removed from Chrome: http://stackoverflow.com/a/23518831/349353

I see, thanks for pointing that out.

Re: CSS Variables in Firefox 31 – new syntax

#19
post #15

These are not like SASS variables. I think calling this variables is causing unnecessary confusion. This feature adds custom properties . CSS had custom vendor properties like `-webkit-foo`, and now you can have your own properties with vendor == "", so it's `--foo`.

I think this is just a problem of nomenclature. In CSS, a statement such as

  font-color : red;
comprises a "property" (left) and a "value" (right). The draft W3C proposal allows you to specify a "custom property" and assign a value to it, thus:

  --header-bg-colour : #ff5533;
You can then reference this elsewhere by saying:

  header { background-color : var(--header-bg-colour); }
Isn't that just how you use a variable (written as $header-bg-colour) in Sass?

Re: CSS Variables in Firefox 31 – new syntax

#20
Does the W3C not have internet access to learn about existing solutions and least try to emulate the good parts?

LESS and SASS are much better about variables, what the heck were they thinking?

    background-color: var(--best-gray-ever);
Not exactly intuitive or easy to parse at a glance.
Post reply on HN