CSS is designed so new syntax degrades instead of breaking the page. Error recovery (CSS Syntax 3) throws away the smallest piece it can:
- A declaration with an unknown property or value is dropped, up to the next
;. Earlier declarations in the block still apply, so writing the fallback first works:width: 100px; width: stretch;. - A style rule is dropped whole if its selector list is invalid. One unknown pseudo-class in
.a, .b:new-statedrops.atoo.:is()and:where()take a forgiving list, so:is(.a, .b:new-state)keeps.a.:has()doesn't. - An at-rule the browser doesn't know is skipped with its whole block.
When a change needs several declarations to move together, or the fallback would conflict with the new value, use a feature query:
@supports (width: stretch) or (width: -webkit-fill-available) { … }
@supports selector(:has(a)) { … }
@supports tests whether the browser accepts a declaration as it would in a style rule. selector() (Conditional 4) tests a selector; newer functions test fonts (font-tech(), font-format()) and at-rules (at-rule(@scope), Chrome 148 and Firefox 157 only). and, or and not need parentheses, and and and or can't be mixed without them; an invalid condition drops the whole @supports rule. JavaScript has CSS.supports().
Three gotchas:
- Unknown syntax is false, not invalid.
@supports not (wobble(3))is true, so anotquery matches in browsers that don't understand what it tests. - Parsing isn't working. A buggy or partial implementation still passes, and
(color: var(--x))is always true becausevar()defers checking. selector()is strict.selector(:is(:new-state))is false even though a rule using it would be kept.
The pattern: write the baseline unconditionally, then layer the enhancement with fallback declarations, forgiving selectors, or @supports.