Post

Custom Properties. Variables is what people wanted. Custom Properties is how they were implemented in CSS. Because they are properties, they are a core part of the language: they cascade, go through the value processing steps, etc. — so much more powerful than just "variables".

1 repost9 likes

Ah so that's where it comes from, like --anchor-name is just a custom property. For var we just access it though var(--prop); I had no idea, I thought they were interchangeable.

No, the values for anchor names are "dashed idents". They are just a name that you give to a thing. You use those names directly in places because there is no value to retrieve: the name --foo _is_ the value. Custom props OTOH are props with a value. Using var() you access the value.

On a sidenote: The reason why things like anchor names are "dashed idents" (with the two dashes) and not just the undashed "custom idents" is for parsing reasons: when used in a shorthand it's easy to see that "--linear" is a user-defined name whereas "linear" could be a name _or_ a keyword.

Cheers, think I got it now 😅. Obviously don't want to allow user defined normal names and say the browser suddenly need this value name and break the web. Custom commands guessing for the same reason. Similar with custom html element having hyphens in the name.