Re:Uses for CSS Custom Properties
by pintxo on Wednesday December 18, 2019 @09:43AM
(#21825287)
Anyone knows the reasoning for using `--` as the prefix for variables?
[ Parent
| on HN ]
They talk about reasons for choosing `--` here: https://www.xanthir.com/blog/b4KT0
TL, DR: There was discussion of using properties that look like `$foo` to define variables, but if they used `$foo` for variables, they would be unable to use it for future "variable-like" things. CSS custom properties behave differently from CSS pre-processor variables and they wanted to make that clear. Additionally, it’s to provide a way for custom properties to be used in any preprocessor.
Presumably they can't just use one dash to avoid clashes with vendor prefixes (-moz-, -webkit- etc.)
I don't think I've ever actually checked, but I always assumed valid CSS property names can only be alpha-dash strings.
Re:Uses for CSS Custom Properties
by have_faith on Wednesday December 18, 2019 @11:55AM
(#21826789)
> I always assumed valid CSS property names can only be alpha-dash strings
They are, although they also aren't allowed to start with a number. But like most things on the web you're not supposed to do some browsers will still let you get away with it.