According the CSS Level 3 specification , for parsing the start of an identifier, you:
Check if three code points would start an identifier
Look at the first code point:
-
, then we have a valid identifier if:
[a-zA-Z_]
or non-ASCII).-
. Otherwise, we do not have a valid identifier start. After determining if we have a valid identifier start, the only requirements to have a valid <ident-token>
is we have 0 or more of any combination of the following:
_
or -
Since we do not require any characters following an identifier start token, this would suggest that --
is a valid identifier, even if never supported by any browser or framework. However, even official CSS validation services (maintained by those that design the CSS specifications) do not consider this a valid identifier. Is this merely a bug in the validation service?
Yes it's valid and it works. It's the shortest custom property (aka CSS variable) that you can define:
body { --:red; background:var(--); }
The --
custom property identifier is reserved for future use , but current browsers incorrectly treat it as a valid custom property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.