Oleg
Chursin
WorkNotesPhotography
How CSS fails

When a browser drops a CSS declaration, rule or selector list, and why "write the fallback first" stops working the moment a var() is involved.

Contents · 11 sections

Here is a bug that is very easy to ship. Someone wants a brand color in a modern color space, with a safe fallback for older engines, so they write the oldest progressive-enhancement pattern in CSS: the old value first, the new value second.

.button {
  background-color: rgb(200 40 40);
  background-color: var(--brand-surface);
}

Then a theme forgets to define --brand-surface, or defines it as 20px by mistake. The button doesn't fall back to the red. It goes transparent. Nothing in the console, no warning, and the "fallback" on the line above is dead code.

The usual explanation of CSS error handling is "the browser ignores what it doesn't understand", and that's true but incomplete. What matters is when the browser finds out it doesn't understand something, and what it has already thrown away by then. A declaration can be lost in three ways. The parser can drop it on its own. The parser can drop the whole rule around it because one selector in the list is bad. Or it can survive parsing, win the cascade, and fail later, while its value is computed for one element. Each discards a different amount, and only the first gives you the fallback behavior people rely on.

This piece walks through all three, with the spec text for each, and ends with a fallback test matrix I ran in four engine builds and a short list of rules for writing CSS that degrades the way you meant it to. It's the third Note in the Reading CSS series, after Why CSS has no version and Feature-detecting CSS when engines half-ship, and it leans on the partial-implementation rule those pieces introduced. Everything below was checked on 18 October 2026.

Fig. 1 is the map for the rest of the piece: where in the pipeline each kind of mistake gets caught.

The parser throws away the smallest thing it can

The contract starts in CSS Syntax Level 3. Its error-handling section is non-normative (the binding behavior lives in the parsing algorithms), but it's the best one-paragraph summary of the design. When errors occur, the parser "attempts to recover gracefully, throwing away only the minimum amount of content before returning to parsing as normal." The section gives the reason too: errors aren't always mistakes, because new syntax looks like an error to an old parser, and the language needs to grow without breaking stylesheets in older browsers.

None of this is new. CSS 2.1's rules for handling parsing errors already said user agents "must ignore a declaration with an unknown property" and "must ignore a declaration with an illegal value", and defined "ignore" precisely: the parser still reads the illegal part to find where it starts and ends, then acts as if it had not been there. Syntax Level 3 is a rewrite of that machinery with nesting, custom properties and a proper tokenizer in mind. On the W3C current-work page it's a Candidate Recommendation Draft, and its Editor's Draft is dated 16 October 2026.

The recovery rules are scoped by context, and they're worth knowing exactly:

  • At the top level, an at-keyword starts an at-rule and anything else starts a qualified rule (in practice, a style rule). The text up to the first { becomes the prelude. The Syntax draft says outright that a bad prelude "may produce an invalid selector", which is "not the concern of the CSS parser". Validation of the selector happens later.
  • Inside a declaration block, unknown syntax makes the parser throw away the declaration it is building and skip to the next semicolon or the end of the block. Then it starts fresh.
  • At the end of the file, anything still open is closed automatically. The Syntax draft's example is .foo { transform: translate(50px with no closing parenthesis or brace: it still parses as a rule with one declaration. An unclosed construct is not invalid in itself, though it may then fail its grammar check.

Nesting changed the inside of a block more than most people realize. Since a block can now hold both declarations and nested rules, the algorithm that consumes a block's contents first tries to parse each item as a declaration. If that doesn't produce a valid declaration, it rewinds and reparses the same tokens as a nested qualified rule, with the semicolon as a stop token. An invalid declaration therefore fails twice, once as a declaration and once as a rule, and is discarded at the semicolon either way. The draft explains why the second attempt doesn't widen the damage: the rule parse stops at the same semicolon, so "the total amount of tokens consumed is the same regardless."

There's one carve-out. Custom properties can hold almost anything, including {} blocks, so a broken custom property reparsed as a rule could stop early at a block and let the rest of its value leak out as new declarations. To prevent that, consume a qualified rule checks whether a would-be rule's prelude starts with --name: when it reaches a {. If it does, inside a block it throws away everything up to the semicolon and returns nothing. The draft calls the case "admittedly very niche", and that's the point: the minimum-damage rule is enforced even where almost nobody will hit it.

.card {
  color: rgb(30 30 30);
  colr: rgb(200 40 40);      /* unknown property: this line only */
  padding: 1rem 2rem 3rem 4rem 5rem; /* too many values: this line only */
  border: 1px solid rgb(0 0 0 / 0.2);
}

Two declarations are dropped there, and the other two apply. That is the behavior people mean when they say CSS is forgiving.

One unsupported value sinks the whole declaration

After each construct is parsed, the Syntax draft says, the user agent checks it against its expected grammar. If it doesn't match, it's invalid, and the browser treats it "as if it wasn't there at all". For declarations, the grammar is the property's value definition, and the browser runs this check at parse time, inside the consume a declaration step: a declaration that isn't valid in the current context is never returned to the stylesheet at all.

The cascade restates the same condition from the other side. Cascade Level 5's Filtering section lists what a declaration needs to apply to an element. It must be in a stylesheet that currently applies, not inside a conditional rule whose condition is false, inside a style rule whose selector matches, and "syntactically valid: the declaration's property is a known property name, and the declaration's value matches the syntax for that property." Only declarations that pass all four become declared values and enter the cascade sort.

The part that catches people is how strict "matches the syntax" is. The CSS Snapshot 2026's rule on partial implementations says user agents must not "selectively ignore unsupported property values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored." Conditional Rules Level 3 builds @supports on the same definition. A processor supports a declaration only if it accepts it rather than discarding it as a parse error, and it must implement "both the property and the value given".

In practice, that means a comma-separated list is all or nothing. A background-image with three layers, one of which uses a gradient function the engine doesn't know, loses all three layers. A font shorthand with one unsupported keyword loses every longhand it would have set. The engine is not allowed to apply the parts it understands, and that rule is what makes the fallback-first pattern safe. If engines did partial parsing, a fallback declaration could be half-overridden by a newer one, and you'd get a blend of both.

Conditional rules fail closed, one condition at a time

At-rules have their own recovery rules, and they're less uniform than declarations.

Media Queries Level 4 replaces a media query that doesn't match the grammar with not all, but only that query. Recovery happens at the next top-level comma, so @media (frobnicate: 1), all keeps working as not all, all. An unknown media feature, or a known feature with an invalid value, has the same result for its query. The draft's example screen and (max-weight: 3kg) and (color), (color) is equivalent to plain (color).

@supports is stricter about its own grammar and gentler about unknown tests. Conditional Rules Level 3 defines a deliberately loose grammar with a <general-enclosed> production that catches future syntax. Anything that matches it but isn't a test the engine knows evaluates to false, not invalid. An @supports rule that doesn't match even the loose grammar is invalid, and the processor ignores the rule and all of its contents. Inside any conditional group rule, an invalid or unknown child rule is dropped without invalidating the group.

The pattern across all of these is the same: the failure is contained to the smallest unit the grammar can isolate. A declaration, a media query, a child rule. The next section is the big exception.

One bad selector drops the whole rule

Selector lists are the place where CSS throws away more than the minimum. The Working Group doesn't defend this. The Selectors draft's compat appendix calls list-wide invalidation "generally considered a legacy mistake by the WG" that "can't be fixed at this point, as too many stylesheets depend on this behavior."

Selectors Level 4's error-handling rules say a selector containing an invalid simple selector, combinator or token is invalid, and "a selector list containing an invalid selector is invalid." An invalid selector "represents, and therefore matches, nothing." Because the selector list is the rule's prelude, an invalid list takes the whole style rule down with it: every declaration in that block is gone for every element.

The spec's own Selector Lists section carries a warning about exactly this. Three rules for h1, h2 and h3 are equivalent to one rule with the list h1, h2, h3 only while all three selectors are valid. Put a typo in the middle one, h2..foo, and the grouped rule is "entirely invalid and the entire style rule is dropped", while the ungrouped version only loses the h2 rule. Selectors Level 4 is a Working Draft on current-work, with an Editor's Draft dated 18 September 2026, but this behavior is as old as selector grouping.

The real-world trigger is rarely a typo. It's a vendor-specific or brand-new selector grouped with standard ones, which the same appendix names as the classic accident: styling an element and a vendor pseudo-element together, "not realizing that this hides the entire rule from other browsers."

/* Broken: an engine that doesn't know one of these drops all of them */
input::placeholder,
input::-moz-placeholder,
input:placeholder-shown:user-invalid {
  color: rgb(110 110 110);
}

Any engine that fails to parse even one of those selectors drops the rule for every input. I ran a variant of this rule in the four engine builds from the matrix later in this piece, with plain :placeholder-shown as the third selector so it would match an untouched input. Chrome, Chromium and WebKit dropped it entirely: neither the placeholder nor the input was styled, and the rule was missing from document.styleSheets. Firefox kept it, and its selectorText showed ::-moz-placeholder rewritten as ::placeholder, so that build treats the prefixed name as an alias. Same stylesheet, opposite outcomes, both correct. The Selectors draft also says, in its note on invalid selectors, that a UA must treat as invalid any pseudo-class, pseudo-element or combinator it has "no usable level of support" for, which is the selector version of the partial-implementation rule. You can't count on an engine half-supporting a selector to keep your rule alive.

The -webkit- exception

There is one deliberate hole, and the spec is candid about where it came from: WebKit-derived engines always accepted any ::-webkit- pseudo-element at parse time, and enough sites came to depend on that for other engines to need it too. Selectors Level 4 Appendix B, which is normative, requires engines to treat every pseudo-element whose name begins with -webkit-, and which isn't functional, as valid at parse time. If the engine doesn't recognize it, it matches nothing and is serialized in lowercase. So ::-webkit-asdf is valid and matches nothing, while ::-webkit-jkl() is invalid. A selector list mixing a standard selector with an unknown ::-webkit- pseudo-element survives in every engine that follows the spec, which is the opposite of what happens with an unknown ::-moz- one.

That compat rule interacts with feature detection. Conditional Rules Level 4 says a selector counts as supported only if the engine accepts all of it and it "doesn't contain unknown -webkit- pseudo-elements". So by that definition, selector(::-webkit-asdf) in @supports is false even though the same selector doesn't invalidate a style rule. The feature-detection Note in this series covers how that played out with Firefox and ::-webkit-scrollbar in 2026.

:is() and :where() forgive, and nothing else does

Selectors Level 4 has one tool for making a list tolerant: the <forgiving-selector-list>. It parses each selector in the list on its own, drops the ones that fail, and keeps the rest. The definition is short and precise:

  • It is used in :is() and :where() only. The draft says the restriction is intentional.
  • Style rules keep the unforgiving behavior. But wrapping a rule's selector in :is() "effectively 'upgrades' it to become forgiving", as long as the selector contains no pseudo-elements, which aren't valid inside :is() or :where().
  • If everything is dropped, :is() with an empty list is valid and matches nothing.
  • Invalid items, whether unknown syntax or known syntax in an invalid context, count as zero specificity.

Fig. 2 runs the spec's h1, h2, h3 example both ways, with an unknown pseudo-class on the middle selector.

The upgrade has a cost, and it's specificity, not matching. The :is() section notes that its specificity is replaced by that of its most specific argument. The draft's example compares :is(ul, ol, .list) > [hidden] with the expanded ul > [hidden], ol > [hidden], .list > [hidden]. A [hidden] child of an ol matches the first with specificity (0,2,0), because .list sets the specificity for every branch, and the second with (0,1,1). Wrapping a list that mixes a class and a type selector makes the type branch harder to override.

:where() has the same syntax and the same forgiving argument, but its specificity is always zero. If you're wrapping a list purely for error tolerance and want to keep overrides easy, :where() is the safer choice, as long as zero specificity is acceptable for that rule. Check that it is: zero loses to any selector that has specificity, including a bare type selector. In my first run of the placeholder tests in this section, an unrelated input { color: … } rule earlier in the sheet beat the :where() rule in all four builds. Both have been Baseline widely available since 21 July 2023, according to webstatus.dev (:is(), :where()) and web-features 3.43.0.

/* Broken: looks forgiving, but ::placeholder is a
   pseudo-element, so it is dropped from the list */
:where(
  input::placeholder,
  input:placeholder-shown:user-invalid
) {
  color: rgb(110 110 110);
}

It's tempting to rescue the earlier placeholder rule this way, and the result is wrong in an instructive way. ::placeholder is a pseudo-element, and pseudo-elements are not valid inside :is() or :where(). Under the forgiving-list rules, the first item is dropped as contextually invalid and the rule only ever styles the :user-invalid case. Forgiving lists forgive pseudo-elements by deleting them. In the four builds, a :where() version of my placeholder variant styled the input but left the placeholder at its UA color, and Chrome went as far as serializing the rule as :where(.wh:placeholder-shown), with the pseudo-element gone. Firefox and WebKit kept the dropped item in selectorText, but it matched nothing.

Rules that target pseudo-elements have to stay as separate rules. Once each rule has a single selector there's no list left to forgive, so there's nothing for :where() to do:

input::placeholder {
  color: rgb(110 110 110);
}

input:placeholder-shown:user-invalid {
  color: rgb(110 110 110);
}

All three selectors involved (::placeholder, :placeholder-shown, :user-invalid) are Baseline widely available per webstatus.dev (::placeholder, :user-invalid), so today the prefixed name only adds risk.

:has() used to forgive, and was changed back

:has() is the cautionary tale. As first specified, it took a forgiving list. Chrome shipped it in version 105, which webstatus.dev dates to 2 September 2022, and csswg-drafts issue #7676, opened the same day, reported the fallout. The issue lays out the mechanism. jQuery has supported its own :has() "for ages", with extensions like :contains() allowed inside it. Its selector engine tries querySelectorAll first and falls back to its own engine only if the native call throws. With a forgiving :has(), ul:has(li:contains('Item')) no longer threw. It quietly dropped the jQuery-only part, and pages got zero matches.

The Working Group resolved on 7 December 2022: "Make has unforgiving", and "Limit forgiving behavior to :is and :where and remove it everywhere else". The Selectors draft's changes since the 11 November 2022 Working Draft record the result: :has() and the selector argument of :nth-child() and :nth-last-child() are no longer forgiving. Today :has() takes a plain <relative-selector-list>.

Chrome's tracking entry, "CSS :has(): Non-forgiving parsing", lists milestone 112. Its status text still says developer trial behind a flag, and chromestatus status text often lags, so I didn't rely on it. The matrix later in this piece checks the current behavior directly. A companion entry, "CSS @supports: Always non-forgiving parsing", implements the matching rule for feature queries: @supports selector(:is(...)) reports unsupported if any argument is unknown, even though the selector itself would be valid in a style rule.

The practical consequence: :has() with an unsupported argument now invalidates the whole selector list it's in, like any other selector. If you need tolerance, wrap the :has() itself in :is(), so the forgiving list is the outer one. :has() has been Baseline widely available since 19 June 2026, per webstatus.dev, so the remaining risk is less about :has() itself and more about the newer pseudo-classes people put inside it.

Writing the fallback first works because the parser decides early

Everything so far explains why the pattern from the opening works at all. CSS Values Level 5's section on first-valid() opens by describing it: authors can declare the same property several times in a rule with different values, and a CSS UA will "use the last one that it understands and throw out the rest."

.badge {
  color: rgb(180 40 40);
  color: oklch(55% 0.2 30);
}

An engine that doesn't know oklch() drops the second declaration at parse time, under the all-or-nothing rule above. It never becomes a declared value, so the first declaration has nothing to compete with and wins. An engine that does know oklch() keeps both, and the second wins the cascade by order of appearance. Either way, each engine gets the best value it can render. (Oklab and OkLCh have been Baseline widely available since 9 November 2025 per web-features 3.43.0, so this exact pair is now mostly historical. The pattern isn't.)

The key detail is when the decision happens. The losing declaration is removed while the stylesheet is parsed, before any element exists to style, so the cascade never sees it. That's why the trick needs no cooperation from the cascade, and why it breaks as soon as the browser can't make the decision at parse time.

var() moves the failure to computed-value time

Custom properties can hold almost anything, and the parser can't know what a var() will turn into on a particular element. So Values Level 5's rules for resolving substitution functions in properties say that if a property value contains one or more arbitrary substitution functions, and those functions are themselves syntactically valid, "the entire value's grammar must be assumed to be valid at parse time." The same section says what happens later: substitution runs during style computation, and if the result "does not match its declared grammar, the declaration is invalid at computed-value time."

That combination is the whole bug from the opening. Here's the spec's own example, from the Invalid Substitution section:

:root { --not-a-color: 20px; }
p { background-color: red; }
p { background-color: var(--not-a-color); }

The p elements get transparent backgrounds, the initial value of background-color, "rather than red backgrounds." The section adds that the same would happen if the custom property were unset, or contained an invalid var(). It also points out the contrast with writing background-color: 20px directly, which would be a normal syntax error, so the red rule would apply.

The mechanism, step by step:

  1. Parse time. Both declarations are valid. The var() one is assumed valid because it contains a well-formed var().
  2. Cascade. Both are declared values for background-color. The later one wins by order. The red one is now discarded for this element.
  3. Computed-value time. The browser substitutes 20px, checks it against the background-color grammar, and fails. The declaration is invalid at computed-value time.
  4. Recovery. For an ordinary property, Invalid Substitution says the computed value becomes the inherited value or the initial value, depending on whether the property inherits, "as if the property's value had been specified as the unset keyword."

The spec's own explanation of why it works this way is the clearest sentence in the whole topic: the concept exists because arbitrary substitution functions "can't 'fail early' like other syntax errors can, so by the time the user agent realizes a property value is invalid, it's already thrown away the other cascaded values." Fig. 3 shows the two paths side by side.

For an inherited property like color, "unset" means the parent's color, not the color you wrote as a fallback. For a non-inherited property like background-color, it means the initial value. Neither is ever your earlier declaration.

Where the guaranteed-invalid value comes from

The failure state has a name. Custom Properties Level 2 defines the guaranteed-invalid value, says it is the initial value of every custom property, and says that if it ever appears in a property value, that property becomes invalid at computed-value time. An empty value is not the same thing: --foo:; is a valid empty value. The draft notes that apart from an unregistered property's initial value, the only way to produce the guaranteed-invalid value is an invalid arbitrary substitution function. A misspelled custom property name and an undefined theme token both produce it. A token holding the wrong type doesn't: 20px substitutes fine and then fails the property's grammar. The using declaration ends in the same state either way, invalid at computed-value time.

Values Level 5's substitution algorithm adds one more route: cycles. If --one refers to --two and --two refers back to --one, substitution detects the cyclic context and every participant becomes invalid at computed-value time. The spec's second example shows that a fallback inside the cycle, var(--three, baz), doesn't help.

Shorthands fail together

Shorthands make the blast radius larger. Normally a shorthand is split into longhands at parse time. With a var() inside, it can't be, because the browser doesn't know what the var() contains. Values Level 5 says each longhand gets a "pending-substitution value", which cascades as normal. Then at computed-value time, after substitution, the shorthand is parsed and the longhands get their values. If that parse fails, every longhand the shorthand was holding fails with it. A margin: var(--space) with a bad token resets all four margins, and a font: var(--type-body) with a bad token resets every font longhand it covers, including any you set earlier in the same rule. I checked the margin case in the matrix builds: margin-left: 10px followed by margin: var(--bad-space), with --bad-space holding a color, computed margin-left to 0px in all four.

Why @supports can't see it

You might expect feature queries to catch this. They can't, and the specs say so. Since a declaration containing a valid var() is assumed valid at parse time, @supports (color: var(--brand)) tests true in any engine that supports custom properties, whatever --brand holds. And the Properties and Values API says every custom property declaration, registered or not, tests true in @supports as long as it fits the very loose generic grammar: @supports (--foo: 1em) is true even if --foo is registered as a <color>. Feature queries look at syntax, and the problem here isn't syntax.

Each fallback tool covers a different failure

The failure is structural, so no single trick restores the old behavior everywhere. Each of the following tools covers one kind of failure and leaves the others open.

Gate the declaration with @supports on a literal value

If the fallback exists because an engine might not support a feature, test the feature with a literal value and put the var() inside the block:

.badge {
  color: rgb(180 40 40);
}

@supports (color: oklch(0% 0 0)) {
  .badge {
    color: var(--badge-color);
  }
}

An engine without OkLCh support never sees the var() declaration, so the red applies. This restores the parse-time decision because the condition is evaluated before the cascade. It does nothing for a token that is undefined or holds the wrong type in an engine that passes the test, and it costs a second rule for every gated declaration. @supports has been Baseline widely available since 30 March 2018 per web-features 3.43.0.

Use var()'s own fallback, for missing tokens only

Custom Properties Level 2's var() section defines the second argument as the substitution value used "when the value of the referenced custom property is the guaranteed-invalid value". That covers a token nobody defined, and a token that is itself invalid at computed-value time, for example because its own var() is broken. It does not cover a token that holds a valid value of the wrong type. --brand: 20px is a perfectly valid custom property value, so var(--brand, red) substitutes 20px, and the declaration fails at computed-value time anyway. The fallback guards against absence, not against mistakes.

Register the property, so a wrong type falls back to your initial value

Registration changes where the failure lands. The Properties and Values API is explicit that registered properties still parse like unregistered ones: "The registered syntax of the property is not checked at parse time." The check happens at computed-value time, on the custom property itself. If its value doesn't parse against the registered syntax, the custom property is invalid at computed-value time, and per Invalid Substitution a registered property with a non-universal syntax gets its inherited or initial value, not the guaranteed-invalid value.

The spec's own example under registerProperty() shows the difference. With --my-color: green; --my-color: url("not-a-color"); color: var(--my-color); and no registration, color ends up as inherit: the green was discarded during parsing because it was superseded by the URL. Register --my-color as a non-inheriting <color> with an initial value of black, and it's --my-color that becomes invalid instead. It takes its initial value, and color is validly black.

@property --badge-color {
  syntax: "<color>";
  inherits: true;
  initial-value: rgb(180 40 40);
}

.badge {
  color: var(--badge-color);
}

A theme that sets --badge-color: 20px now makes --badge-color itself invalid at computed-value time, and the badge gets a real color instead of whatever color would have inherited. Which color depends on inherits. Per Invalid Substitution the registered property behaves as unset, so with inherits: true, as here, it takes the parent's --badge-color, which is the registered initial value unless an ancestor set a valid one. With inherits: false it's always the initial value, which is what the matrix below tests. That's the closest thing to a typed fallback CSS has today. Three costs. You don't get your earlier declaration back, you get one global default per property, set once in the registration. Registration is document-wide, shadow trees included: the Shadow DOM section says all registrations "interact in a single global registration map for the Document", so a component can't define its own default for a shared token name. And registered custom properties are Baseline newly available, not widely: webstatus.dev dates it to 9 July 2024, when Firefox 128 shipped. Under Baseline's 30-month rule, it becomes widely available on 9 January 2027. In an engine without registration support, the @property rule is ignored and you're back to unregistered behavior.

There's also a spec change that engines haven't caught up with. Until this year the @property rule required syntax and inherits, plus initial-value for any syntax other than "*"; if one was missing, the whole rule was invalid, and MDN's @property page still documents that. In csswg-drafts issue #13211 the Working Group resolved on 11 March 2026 to "make all property descriptors in @property optional", and the current Editor's Draft of the @property rule, dated 6 August 2026, says all descriptors are optional and an invalid initial-value is ignored. The matrix below includes an @property rule with no inherits descriptor, and every engine build I tested still dropped it. Write all three descriptors until that changes. A separate open issue, #14425, asks for duplicate-descriptor fallbacks inside @property; its opening example, two initial-value lines with the newer value last, "doesn't work" today.

first-valid(): specified, not shipped

The Working Group's direct answer to this problem is first-valid(), resolved in issue #5055 in January 2022 and edited into Values Level 5 in September 2024, according to the editor's closing comment on that issue. It "inlines the fallback behavior intrinsic to parsing declarations": it takes a comma-separated list of arbitrary values and represents the first one the UA parses as valid for the property. If none is valid, the property is invalid at computed-value time.

/* Specified in CSS Values 5; no engine ships it (October 2026) */
.badge {
  color: first-valid(var(--badge-color), rgb(180 40 40));
}

The point is that the validity check runs after substitution, so a wrong-typed token falls through to the next argument. Do not use it yet. I found no implementation anywhere: no first-valid entry in web-features 3.43.0, no mention anywhere in MDN's browser-compat-data 8.1.6, a chromestatus search that returns zero features, and 404s for the likely MDN reference URLs, all on 18 October 2026. In an engine that doesn't support it, the parser doesn't know the function, but the declaration contains a var(), so it's assumed valid at parse time anyway and fails at computed-value time. The matrix confirms that's exactly what happens. A first-valid() declaration without a var() inside is dropped at parse time in the same engines, so your earlier declaration survives.

The Values Level 5 Editor's Draft is dated 4 September 2026 and the module is a Working Draft on current-work. The function still carries an inline issue, "Should this have a different name?", and the parse-time question is still open; I come back to both at the end.

if() with supports() inherits the same failure

Values Level 5's if() can test supports() inline, which looks like a way to put a feature query inside a value. But if() is itself an arbitrary substitution function, so a declaration using it is assumed valid at parse time, and a broken branch fails at computed-value time with the same unset behavior. if() is also Chromium-only: webstatus.dev lists it as limited, shipping in Chrome since 27 May 2025, with no Firefox or Safari implementation. It gets its own Note later in this track. For fallbacks, it changes nothing about the analysis above.

Four engine builds agree with the spec on every case

Spec text tells you what engines should do. To see what they do, I ran each strategy against a supported and an unsupported value and recorded the computed result. The test page is a single HTML file. Each case is one <p> with one class, the body has color: rgb(0, 0, 0), and "red" in every rule is the earlier fallback, so red in the results means the fallback survived. The core of the <style> block:

:root { --bad: 20px; }

@property --reg {
  syntax: "<color>";
  inherits: false;
  initial-value: rgb(0, 0, 255);
}
@property --noinherits {
  syntax: "<color>";
  initial-value: rgb(0, 0, 255);
}

.dup-bad { color: rgb(255, 0, 0); color: nonsense-color(1); }
.var-bad { color: rgb(255, 0, 0); color: var(--bad); }
.var-missing { color: rgb(255, 0, 0); color: var(--missing); }
.var-fb-missing {
  color: rgb(255, 0, 0);
  color: var(--missing, rgb(0, 128, 0));
}
.var-fb-wrong {
  color: rgb(255, 0, 0);
  color: var(--bad, rgb(0, 128, 0));
}
.reg { --reg: 20px; color: rgb(255, 0, 0); color: var(--reg); }
.noinherits {
  color: rgb(255, 0, 0);
  color: var(--noinherits, rgb(0, 128, 0));
}
.fv { color: rgb(255, 0, 0); color: first-valid(var(--bad), green); }
.sel-bad, .x:frobnicate { color: rgb(255, 0, 0); }
:is(.sel-forgiving, .x:frobnicate) { color: rgb(255, 0, 0); }

The script at the end of the page reads one computed value per element, plus three feature queries:

const results = {};
for (const p of document.querySelectorAll('p')) {
  results[p.className] = getComputedStyle(p).color;
}
// The spec's example sits on a div with class "bg"
results.bg = getComputedStyle(document.querySelector('.bg')).backgroundColor;
results.supportsVar = CSS.supports('color', 'var(--bad)');
results.supportsIs = CSS.supports('selector(:is(.x:frobnicate))');
results.supportsReg = CSS.supports('--reg: 20px');
console.log(JSON.stringify(results));

The full page also covers the duplicate-declaration pattern with a supported value, @supports gating, a literal-only first-valid(), :has() with an unknown argument (bare and wrapped in :is()), an unknown media feature in a media query list, and the spec's background-color example.

Method. I ran it on 18 October 2026 on macOS, headless, driven by Playwright 1.64.1, in four builds: Google Chrome 155.0.8059.80 (the installed stable channel), Playwright's Chromium 156.0.8078.4, a Playwright Firefox build reporting 155.0, and a Playwright WebKit build whose user agent reports Version/27.2. The last two are patched engine builds, not the shipping browsers. Playwright's documentation says its Firefox "relies on patches" and tracks a recent Firefox Stable, and that its WebKit is derived from WebKit's main branch "often before these updates are incorporated into Apple Safari". So treat those two columns as "this engine, at this build", not as "Firefox 155" or "Safari 27". I ran the page twice that day and got identical results. The shorthand row comes from a second small page run in the same four builds.

Result. All four builds agreed on every case in the table:

Case What it tests Computed result Meaning
color: red; color: oklch(...) duplicate, supported oklch(0.55 0.2 30) newer value wins
color: red; color: nonsense-color(1) duplicate, unsupported red parse-time drop, fallback works
color: red; color: var(--bad) wrong-typed token black (inherited) invalid at computed-value time
color: red; color: var(--missing) undefined token black (inherited) invalid at computed-value time
var(--missing, green) var() fallback, missing token green fallback used
var(--bad, green) var() fallback, wrong type black (inherited) fallback not used
registered <color>, value 20px @property with initial blue blue registered initial value
@property without inherits descriptor now optional in the ED green (the var() fallback) rule still rejected
@supports (color: nonsense-color(1)) around a var() gating, unsupported red gated declaration never seen
@supports (color: oklch(...)) around a var() gating, supported oklch(0.55 0.2 30) gated declaration applies
first-valid(nonsense-color(1), rgb(0, 128, 0)) no var() inside red unknown function, dropped at parse time
first-valid(var(--bad), green) var() inside black (inherited) assumed valid, then fails
.sel-bad, .x:frobnicate unforgiving list black whole rule dropped
:is(.sel-forgiving, .x:frobnicate) forgiving list red bad item dropped
.has-bad:has(.y:frobnicate), .has-bad :has() with unknown argument black whole rule dropped
:is(.has-wrapped:has(.y:frobnicate), .has-wrapped) same, wrapped red bad item dropped
@media (frobnicate: 1), all unknown media feature red only that query is not all
background-color: red; background-color: var(--bad) the spec's example rgba(0, 0, 0, 0) initial value, transparent
margin-left: 10px; margin: var(--bad-space) shorthand, wrong-typed token margin-left: 0px every longhand reset
CSS.supports('color', 'var(--bad)') feature query with var() true can't see the problem
CSS.supports('selector(:is(.x:frobnicate))') feature query, forgiving selector false non-forgiving in @supports
CSS.supports('--reg: 20px') registered <color> true custom properties always pass

Two results are worth calling out. The :has() rows show that all four builds now implement the 2022 resolution: an unknown argument invalidates the whole list, whatever chromestatus's status text says. And the @property row shows the March 2026 descriptor change hasn't reached any of these engines yet. Everything else matches the spec text quoted above, row for row. The one case where the builds disagreed was the placeholder selector list from earlier, and there the spec predicts disagreement: Firefox knows ::-moz-placeholder, the others don't. What this matrix doesn't tell you is anything about current Firefox or Safari releases, older engines, or mobile builds. If your support matrix includes those, the page is small enough to run there yourself.

Rules for CSS that fails the way you meant

These follow from the mechanism above. Where a rule depends on engine behavior rather than spec text, the matrix backs it in the four builds I could run.

Never rely on cascade fallback for a declaration that contains var(). The earlier declaration is dead code the moment the var() declaration wins the cascade. If the risk is an engine that lacks a feature, gate the var() declaration with @supports on a literal value. If the risk is a token that might be missing, use var()'s second argument. If the risk is a token that might hold the wrong type, register the property with a sensible initial value.

Register tokens that cross a team boundary. Design-system tokens are exactly the case where the person setting the value isn't the person using it. A <color>, <length> or <number> registration turns "transparent button in production" into "button in the default color". Write syntax, inherits and initial-value every time, whatever the current draft says: every build I tested still rejected a rule without inherits. Budget for the fact that registration is only Baseline newly available until January 2027.

Keep shorthands out of the token path when a failure would be expensive. A bad token in font: var(--type) resets every font longhand it covers. Tokenizing longhands (font-size: var(--type-size)) limits the damage to one property.

Wrap selector lists that mix new or vendor pseudo-classes in :where(), or :is() if you need the specificity. Split out anything with a pseudo-element, since forgiving lists drop pseudo-elements, by spec and in all four builds. Put :has() inside the forgiving wrapper, never the other way around. And remember that a :where() rule loses to a bare input or button rule anywhere in the cascade.

Don't use @supports to detect bad tokens. It tests syntax. A declaration with a well-formed var() passes, and so does every custom property declaration, registered or not.

Leave first-valid() and if() out of fallback code for now. The first has no implementation I could find, and the second is Chromium-only and fails the same way var() does.

Test computed values, not stylesheets. A linter can catch a misspelled property. It can't catch a token that is valid CSS and the wrong type. The only way to see invalid-at-computed-value-time failures is to compute styles in an engine, which is why the matrix above uses getComputedStyle(). For a design system, a small page that renders every component with every theme and asserts on a handful of computed values catches this whole class of bug.

What we don't know

Whether any engine will ship first-valid(), and under what name. On 18 October 2026 I found no entry in web-features 3.43.0, no compat data, no chromestatus feature and no MDN page, and every build in the matrix dropped it as an unknown function. The Values Level 5 draft carries an inline issue asking whether it should have a different name; the January 2022 resolution asked for a naming discussion "once we better understand the scope". An implementation intent on chromestatus or a WebKit or Mozilla standards position would settle the first question.

When first-valid() is validated. The spec text says that if no argument is valid the property is invalid at computed-value time. Issue #10989, open since October 2024, asks for parse-time resolution instead. In issue #11136, Tab Atkins, one of the Values Level 5 editors, wrote in January 2025 that with only literal arguments it is resolved at normal parse time, which would make an all-invalid first-valid() a parse error and keep your earlier declaration. The Editor's Draft text hadn't been updated to say so when I checked. Until it is, there are two readings, and they disagree about whether the fallback-first pattern survives.

When engines adopt optional @property descriptors. The resolution in issue #13211 is from March 2026 and is in the Editor's Draft, but every build I tested still rejects a rule without inherits. I found no Web Platform Tests run or browser bug to point to, so I can't say whether any engine has an implementation in progress.

Whether the shipping Firefox and Safari releases behave like the Playwright builds. The Firefox and WebKit results above come from Playwright's patched builds (one reporting Firefox 155.0, one whose user agent says Version/27.2), not from the browsers users run. I expect no difference for behavior this old and this well tested, but I haven't measured it, and the @property and :has() rows are the ones most likely to change between releases.

How older engines handled the :has() change. Chrome 105 shipped a forgiving :has(), and the chromestatus entry for the unforgiving version lists milestone 112 with a status that still reads developer trial. Which stable releases parsed :has() forgivingly, in Chromium and in Safari (which shipped :has() first, in March 2022 per webstatus.dev), is something only per-version testing or release notes would confirm. If your support matrix still includes 2022-era engines, test there.

References

  1. CSS Syntax Module Level 3 - Error Handling (Editor's Draft, 16 October 2026). CSS Working Group. Accessed .
  2. CSS Syntax Module Level 3 - Consume a qualified rule. CSS Working Group. Accessed .
  3. CSS Syntax Module Level 3 - Consume a block's contents. CSS Working Group. Accessed .
  4. CSS Syntax Module Level 3 - Consume a declaration. CSS Working Group. Accessed .
  5. CSS 2.1 - Rules for handling parsing errors. W3C. Accessed .
  6. CSS current work and how to participate. W3C. Accessed .
  7. CSS Cascading and Inheritance Level 5 - Filtering (Editor's Draft, 13 April 2026). CSS Working Group. Accessed .
  8. CSS Snapshot 2026 - Partial Implementations (W3C Group Note, 22 June 2026). W3C CSS Working Group. Accessed .
  9. CSS Conditional Rules Module Level 3 - Definition of support (Editor's Draft, 8 October 2026). CSS Working Group. Accessed .
  10. CSS Conditional Rules Module Level 3 - The @supports rule. CSS Working Group. Accessed .
  11. CSS Conditional Rules Module Level 4 - Extensions to the definition of support (Editor's Draft, 8 October 2026). CSS Working Group. Accessed .
  12. Media Queries Level 4 - Error Handling (draft dated 8 October 2026). CSS Working Group. Accessed .
  13. Selectors Level 4 - Invalid Selectors and Error Handling (Editor's Draft, 18 September 2026). CSS Working Group. Accessed .
  14. Selectors Level 4 - Selector Lists. CSS Working Group. Accessed .
  15. Selectors Level 4 - <forgiving-selector-list>. CSS Working Group. Accessed .
  16. Selectors Level 4 - The Matches-Any Pseudo-class: :is(). CSS Working Group. Accessed .
  17. Selectors Level 4 - The Specificity-adjustment Pseudo-class: :where(). CSS Working Group. Accessed .
  18. Selectors Level 4 - The Relational Pseudo-class: :has(). CSS Working Group. Accessed .
  19. Selectors Level 4 - Changes since the 11 November 2022 Working Draft. CSS Working Group. Accessed .
  20. Selectors Level 4 - Appendix B: Obsolete but Required -webkit- Parsing Quirks. CSS Working Group. Accessed .
  21. csswg-drafts #7676: The forgiving nature of :has breaks jQuery when used with a complex :has selector. CSS Working Group (GitHub). Accessed .
  22. csswg-drafts #7676 - RESOLVED: Make has unforgiving (7 December 2022). CSS Working Group (GitHub). Accessed .
  23. Chrome Platform Status - CSS :has(): Non-forgiving parsing. Google. Accessed .
  24. Chrome Platform Status - CSS @supports: Always non-forgiving parsing. Google. Accessed .
  25. CSS Values and Units Module Level 5 - first-valid() (Editor's Draft, 4 September 2026). CSS Working Group. Accessed .
  26. CSS Values and Units Module Level 5 - if(). CSS Working Group. Accessed .
  27. CSS Values and Units Module Level 5 - Substitution. CSS Working Group. Accessed .
  28. CSS Values and Units Module Level 5 - Resolving in Properties. CSS Working Group. Accessed .
  29. CSS Values and Units Module Level 5 - Invalid Substitution. CSS Working Group. Accessed .
  30. CSS Values and Units Module Level 5 - Substitution in Shorthand Properties. CSS Working Group. Accessed .
  31. CSS Custom Properties for Cascading Variables Level 2 - Guaranteed-Invalid Values (Editor's Draft, 9 October 2026). CSS Working Group. Accessed .
  32. CSS Custom Properties for Cascading Variables Level 2 - The var() notation. CSS Working Group. Accessed .
  33. CSS Properties and Values API Level 1 - Parse-Time Behavior (Editor's Draft, 6 August 2026). CSS Working Group (Houdini). Accessed .
  34. CSS Properties and Values API Level 1 - Computed Value-Time Behavior. CSS Working Group (Houdini). Accessed .
  35. CSS Properties and Values API Level 1 - Conditional Rules. CSS Working Group (Houdini). Accessed .
  36. CSS Properties and Values API Level 1 - The registerProperty() function. CSS Working Group (Houdini). Accessed .
  37. CSS Properties and Values API Level 1 - The @property rule. CSS Working Group (Houdini). Accessed .
  38. CSS Properties and Values API Level 1 - Shadow DOM. CSS Working Group (Houdini). Accessed .
  39. csswg-drafts #13211: @property descriptors should be optional whenever possible. CSS Working Group (GitHub). Accessed .
  40. csswg-drafts #14425: Descriptors should support fallbacks. CSS Working Group (GitHub). Accessed .
  41. @property - MDN Web Docs. Mozilla. Accessed .
  42. csswg-drafts #5055: Allow an inline way to do "first value that's supported". CSS Working Group (GitHub). Accessed .
  43. csswg-drafts #10989: Resolve first-valid() at parse time. CSS Working Group (GitHub). Accessed .
  44. csswg-drafts #11136: Using first-valid() and interpolate() in shorthands. CSS Working Group (GitHub). Accessed .
  45. web-features 3.43.0 data.json. W3C WebDX Community Group. Accessed .
  46. Web Platform Status - Registered custom properties. Web Platform Status (webstatus.dev). Accessed .
  47. Web Platform Status - :has(). Web Platform Status (webstatus.dev). Accessed .
  48. Web Platform Status - :is(). Web Platform Status (webstatus.dev). Accessed .
  49. Web Platform Status - :where(). Web Platform Status (webstatus.dev). Accessed .
  50. Web Platform Status - ::placeholder. Web Platform Status (webstatus.dev). Accessed .
  51. Web Platform Status - :user-valid and :user-invalid. Web Platform Status (webstatus.dev). Accessed .
  52. Web Platform Status - if(). Web Platform Status (webstatus.dev). Accessed .
  53. Chrome Platform Status API - search for "first-valid". Google. Accessed .
  54. MDN browser-compat-data (package 8.1.6 checked). Mozilla. Accessed .
  55. Baseline. web.dev (Google). Accessed .
  56. Playwright - Browsers. Microsoft. Accessed .

Found this useful? Pass it on.

Set in Archivo on a twelve-column grid. Built with Lit web components and rendered to static HTML.

© 2026 Oleg Chursin
Brooklyn, New York