CSS Variables in Firefox 31 – new syntax
41–50 of 54 posts
Re: CSS Variables in Firefox 31 – new syntax
#42Re: CSS Variables in Firefox 31 – new syntax
#43Does 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.
I don't know, maybe about how to design a spec that is compatible with past and future CSS parsers and features?
People think it's so simple to come up with a new feature for CSS/HTML/JS, when actually, they have no idea how difficult it is.
They're smarter than that: http://www.xanthir.com/blog/b4KT0
Re: CSS Variables in Firefox 31 – new syntax
#44Does 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.
> what the heck were they thinking? I don't know, maybe about how to design a spec that is compatible with past and future CSS parsers and features? People think it's so simple to come up with a new feature for CSS/HTML/JS, when actually, they have no idea how difficult it is. They're smarter than that: http://www.xanthir.com/blog/b4KT0
> what the heck were they thinking?
...At first place when they wrote CSS.
CSS is a disaster,and one of the worst spec ever written in my book.
> People think it's so simple to come up with a new feature for CSS/HTML/JS, when actually, they have no idea how difficult it is.
Aside from HTML,CSS and JS are "defacto" standards since vendors werent able to agree on a better spec when they should have. only developpers can fix these with tools they build.Devs cant rely on these technologies on their own.That's why they have CSS and JS preprocessors.Because while it's crap at the end of the day devs need to build on top of that crap.
Re: CSS Variables in Firefox 31 – new syntax
#45Earlier quoted context omitted.
And does your styling work in a webbrowser where JS is disabled?
Not trolling, I really don't understand: why would you disable JS when browsing the web?
Running JavaScript in your browser automatically from any site that you visit is pretty darn scary when you think about it. You can protect from a whole host of vulnerabilities by disabling it, and then whitelisting only hosts which you trust.
Re: CSS Variables in Firefox 31 – new syntax
#46Earlier 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…
Once an easy-to-use syntax is published, toolchains that parse CSS will update as fast as they can! But "--"? Everybody will stick to the old standard and never want to upgrade.
Re: CSS Variables in Firefox 31 – new syntax
#47Does anyone know if the var() function only work with the variables? For example, can I do something like: background-color: var(color);?
background-color: currentColor;
Fully supported in all modern browsers. http://devdocs.io/css/color_value#currentColor_keywordRe: CSS Variables in Firefox 31 – new syntax
#48Can anyone think of a use case for this beyond what a precompiler (Sass, Less, Stylus) can do?
The CSS use a couple of custom properties that define the foreground and background colors. Then, some elements redefine those custom properties (through CSS or JS) and that in turn makes all their children inherit the new custom properties' values and change their styles. This makes the rules that use the custom properties very general, and avoids the need to write more specific rules for the alternative colors. I hope this makes sense :)
I don't think this is possible to do with CSS preprocessors.
Re: CSS Variables in Firefox 31 – new syntax
#49Earlier quoted context omitted.
As other posts have stated, CSS variables are not the same thing as preprocessor variables. Specifically, they cascade. A preprocessor cannot possibly implement CSS variables with cascading because it the value is resolved against a live context. In other words, you can actually change the variable at runtime with rules that target different selectors. As such, the "variables" are in fact functions.
Thanks for the break down. I'm not seeing the benefit of variables cascading, though.
Re: CSS Variables in Firefox 31 – new syntax
#50Writing your styles in javascript is a better option. You get variables, as well as functions and modules (e.g. with browserify), all with sane syntax and semantics (no "cascade"). Preprocessors are an inferior solution, limited by the semantics of CSS and leading, by the pervasive use of macros, to needlessly large CSS file sizes.
What's the best solution for writing styles exclusively in JS and avoiding CSS completely?