
CSS Support Gates: @supports and Fallback-First Code
Unsupported browsers should land on a designed state, not an accident. Cascade-order fallbacks, feature-query craft, the gate inversion that drops the fallback in engines older than @supports, and gate removal.
TL;DR: Adopting a new CSS primitive is not one decision but two, and only one of them is yours to make inside a stylesheet. The organizational question — which browsers a product supports at all — is settled elsewhere. The authoring question is what your component does in an engine that lacks the feature, and the answer has to be a designed state rather than an accident. This article covers cascade-order fallbacks, where a feature query earns its place, the gate-the-enhancement rule and the inversion that breaks it, element-level fallbacks that need no conditional code at all, and the discipline of actually rendering the degraded path before shipping it.
Two jobs, one word
"Browser support" names two different jobs, and conflating them is how support conversations go in circles.
The first is a policy question: which engines and versions a product commits to, what the analytics say about the users behind those numbers, and how that threshold is reviewed over time. That is a strategic decision made above the component, with its own literature and its own decision-makers, and this piece defers to it entirely.
The second is the authoring question, and it arrives on your desk fully formed: given the floor the policy handed you, how does this component behave in an engine below the feature you want to use? That question has a stylesheet answer, and writing that answer well is a craft with recognizable patterns.
The principle underneath all of them is worth stating once, plainly. Engines without the feature must land on a designed state — something a designer would sign off on, not merely something that does not throw. The fallback is a deliverable. It is the reason the enhancement is safe to ship at all, and treating it as an afterthought is how a component that looked finished in review turns out to be broken for part of the traffic.
Fallback-first: the cascade is the first gate
The cheapest gate is not a feature query. It is declaration order, and it has been part of CSS since the beginning: engines discard declarations they cannot parse and keep what they already applied.
.panel {
/* parsed everywhere */
max-width: 40rem;
/* discarded by engines that do not know the unit */
max-width: 60ch;
}An engine that does not understand the second declaration simply never applies it, and the first one stands. Nothing is tested, nothing is branched, and there is no gate to remove later — the fallback and the enhancement live two lines apart, which also means nobody can accidentally delete one without seeing the other.
This works whenever the upgrade is a single property taking a value the old engine will not parse: a newer unit, a newer function, a newer keyword. It also relies on the same rule a feature query evaluates. The CSS Conditional Rules specification counts a declaration as supported when the engine accepts it within a style rule rather than discarding it as a parse error, and an engine that does not implement both the property and the value with a usable level of support must not accept it or claim support for it. Declaration order gets that answer without any conditional block.
It stops working the moment the new feature changes structure or behavior rather than one value. If the enhancement means a different layout, a different set of elements participating, or a rule that only makes sense when several new declarations apply together, declaration order cannot express it — an engine will happily apply half of your new mechanism and produce something neither designed nor working. That is precisely where a feature query earns its cost.
@supports craft
A feature query tests a declaration or a selector — the two forms this section uses — and applies a block only when the engine understands it. (The Level 5 Working Draft of CSS Conditional Rules also defines font-tech(), font-format() and at-rule() tests, plus named conditions from an @supports-condition rule.) Declaration and selector tests both matter, because new CSS arrives in both shapes.
/* property test */
@supports (anchor-name: --menu) {
.menu-trigger { anchor-name: --menu; }
.menu { position-anchor: --menu; top: anchor(bottom); left: anchor(left); }
}
/* selector test */
@supports selector(:has(*)) {
.field:has(:user-invalid) { --field-border: var(--color-danger); }
}The single most important rule is which side of the query the fallback sits on. Gate the enhancement, not the baseline. The unguarded code is what every engine gets; the guarded block adds the primitive on top. The inversion is common enough to be worth showing:
/* WRONG — engines older than @supports get nothing */
@supports not (anchor-name: --menu) {
.menu { /* the fallback, hidden behind a negative test */ }
}
@supports (anchor-name: --menu) {
.menu { /* the enhancement */ }
}
/* RIGHT — the fallback is unconditional, the enhancement is added */
.menu {
position: absolute;
top: 100%;
}
@supports (anchor-name: --menu) {
.menu-trigger { anchor-name: --menu; }
.menu { position-anchor: --menu; top: anchor(bottom); left: anchor(left); }
}The wrong version is not merely inelegant. Feature queries are themselves a feature, so an engine old enough to predate @supports skips both blocks, and the fallback disappears in those engines. An engine that supports @supports but lacks the primitive does match the negated test and applies the fallback, so this failure is limited to engines older than @supports itself. The right version has no such failure mode: the baseline applies to everything, including engines nobody tested.
Two habits keep gates maintainable. Combine conditions with and or or only when the features genuinely depend on each other — a mechanism that needs two new properties to make sense should be gated on both, so no engine gets half of it. And keep gates coarse: one gate per capability, wrapping the whole enhancement, rather than a query around each declaration. A file with fourteen small feature queries is a file nobody can reason about or clean up later. (There is a JavaScript equivalent in CSS.supports() for the rare case where scripting must branch on the same fact; stylesheet authoring is the subject here.)
@supports itself has been available across browsers since September 2015, and the selector() function since Safari 14.1 joined Chrome 83 and Firefox 69 in April 2021 (MDN, accessed August 2026). The gate mechanism is not the thing you need to worry about supporting.
HTML-level fallbacks
Some of the newer primitives do not need a stylesheet gate at all, because the element degrades on its own.
The pattern shows up wherever a feature is opt-in at the markup or property level and the un-upgraded rendering is the platform default. A control that only enters a fully styleable mode when a specific property is set renders as the native control everywhere else. An attribute that groups elements into exclusive behavior is ignored by engines that do not know it, leaving the elements behaving independently. A newer pseudo-element that exposes an internal region simply matches nothing, so the transition it was driving does not happen and the state change is instant.
The virtue is that there is zero conditional code. The fallback is not something you wrote; it is what the markup already means in an older engine. Nothing can rot, because there is no gate to outlive its usefulness.
What this pattern does require is a conversation before the enhancement ships, and it is a design conversation rather than an engineering one. Someone has to look at the native-rendered state, or the un-animated state, and agree that it is acceptable. That agreement is cheap to get in advance and expensive to get retroactively, in a bug report, from a designer who never saw it.
Testing the degraded path
A fallback nobody has looked at is a hypothesis. Treat it as a rendering target: turn the feature off in browser developer tools where the engine offers that, or open the component in an engine that genuinely lacks the primitive, and look at the result with the same attention the enhanced path got. Many fallback bugs are not subtle — a control with no visible affordance, a menu positioned in the wrong corner, a panel that opens with the content still hidden — and they are all obvious the first time anyone actually renders them.
Record the decision where it can be reviewed. A sentence in the pull request stating what unsupported engines get and why that is acceptable turns an implicit judgment into a reviewable one, and gives the next person a reason rather than a mystery. "Without the anchor primitive the menu falls back to absolute positioning against the wrapper, which is correct on all our layouts except the compact toolbar, where it sits four pixels low" is a complete decision. Its absence is how a team discovers, much later, that nobody ever chose the degraded behavior.
The counterpart discipline is removal. Gates outlive their usefulness: once a primitive that needed a query when the component was written reaches broad interoperability, the query costs more than it protects — extra nesting, a fallback branch nobody maintains, and a false impression that the feature is still risky. Baseline vocabulary is a reasonable common reference for the timing conversation (web.dev, accessed August 2026). Deleting the gate and the fallback together is the same craft as writing them, and it wants the same evidence: check the current support state, note the date you checked, and remove both in one commit that says what it verified.