by micheljansen · 14y ago · 0 comments
:root {
var-header-color: #06c;
}
h1 {
background-color: var(header-color);
}
Compare that to Less: @header-color: #06c;
h1 {
background-color: @header-color;
}
I can understand why they opted out of the @-notation in favor of something a bit more in line with existing CSS, but it just looks overly complicated to me. $header-color: #06c;
h1 {
background-color: $header-color;
} :vars {
header-color: #06c;
header-font: helvetica;
}
h1 {
font-family: $header-font;
background-color: $header-color;
}:root { var-color: #000; }
p { var-color: #666; }
* { color: var(color) }
"As defined here, the syntax for variable usage is different from the syntax for variable definition (i.e. var-foo for definition, var(foo) for usage). Some have suggested that the syntaxes should should match, using functional syntax in both cases. Others have suggested using a prefixed symbol instead of functional syntax (e.g. $foo) for both the property and usage."
As I understand it, at-rules are basically directives to the CSS parser and, according to the spec, should be ignored if the parser does not recognize the identifier. Given that, the use of at-rules for variable names has always seemed, IMVHO, to break the purpose of at-rules.