This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
I recently read Hybrid positioning with CSS variables and max() by Lea Verou and came across a CSS fact that was complete news to me.
The browser doesn’t know if your property value is valid until the variable is resolved, and by then it has already processed the cascade and has thrown away any potential fallbacks.
She describes that when you're using CSS custom properties and the variables turn out to be invalid, fallback mechanisms are no longer possible. You can read more about it in the CSS spec about invalid CSS custom properties.
It includes the following example:
:root { --not-a-color: 20px; }
p { background-color: red; }
p { background-color: var(--not-a-color); }
The above CSS code won't render paragraphs with a red background color. ?
If you want to learn more about it, Jeremy Keith was surprised by an article about this, too, and wrote about it quite nicely.
(which is why I'm not writing about it more detailed)
But... I made a little #devsheet about it. ?
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Stefan Judis | Sciencx (2020-06-28T22:00:00+00:00) Custom properties affect how invalid CSS declarations are handled (#tilPost). Retrieved from https://www.scien.cx/2020/06/28/custom-properties-affect-how-invalid-css-declarations-are-handled-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.