With the introduction of css vars, I would like to know why the argument -- was chosen as a way of noting var.
Given that CSS has a semi-special function calc , it seems to me that -- can be easily confused for the decrement operator in other languages.
I am curious if there is any historical significance or technical limitations that led to the choice. The double, in particular, puzzles me when CSS markers are usually singles (#,., @ Etc). It is also useful to use a character already used by other things (especially when its value for the class name begins with -- ).
Example:
@custom-media --lt-sm (width < 576px); --grey300: #e0e0e0; .navbarItem { display: inline-block; text-align: center; border-top: 1px solid var(--grey300); border-left: 1px solid var(--grey300); @media (--lt-sm) { flex-grow: 1; } &:last-child { border-right: 1px solid var(--grey300); } }
Renouncement
Some may argue the truth of this question, but understanding why is a key method of remembering a specific concept.
The only discussion I can find is related to it:
At telcon today, we decided to use the "-" prefix to indicate custom properties and other custom things.
We discussed whether the prefix is ββsupported or not when referencing a custom property from the var () function, but does not actually solve it. The discussion in the call leaned toward a prefix, as it is currently with var- * properties, but on some sides the discussion with Simon and Sylvanas claimed that they used the full name because there are confusing cases, such as "-0" or "- - "
So, although I understand the potential confusion caused by the authors perhaps by thinking that var () can accept any property name as an argument, I think this reversed the confusion that one needs to escape in various circumstances. Escape rules are always very confusing for the authors, so I'm going to go with "use the regular property name literally as the var () argument.
Link:
http://lists.w3.org/Archives/Public/www-style/2014Mar/0467.html
https://www.w3.org/TR/css-variables/#defining-variables