Progressive Enhancement: Fallbacks, @supports and Writing CSS That Degrades Gracefully
How to use new CSS safely: start from a working baseline and add enhancements, using the cascade's error handling for fallbacks, @supports feature queries with and, or, not and selector(), forgiving selectors, and how to choose a browser support target.
kvi5hnuCode Sprout team member10 min readOn this page
Not every visitor has the newest browser, and CSS features arrive in different browsers at different times. You don't have to wait until a feature works everywhere, and you don't need scripts to detect it. Progressive enhancement means building a version that works in every browser first, then adding improvements that browsers apply only when they support them. CSS is built for this: browsers ignore what they don't understand (article 3), and @supports lets you ask directly whether a feature is available.
Start with something that works
A page that looks plainer in an older browser is fine. A page that's broken, such as text that overlaps or a menu that never appears, isn't. So the first question for any new feature is: what does a browser without it show?
- Purely decorative features, such as
text-wrap: balance, smooth scrolling, a nicer focus ring or an entry animation, can be used freely. Without support, the page simply looks a little less polished. - Features that change layout or hide content, such as anchor-positioned menus, container queries or masonry layouts, need a fallback that still lays the content out readably.
Fallbacks with the cascade
Because browsers drop declarations they can't parse, the simplest fallback is two declarations, the safe one first:
.hero {
min-height: 100vh; /* older browsers */
min-height: 100dvh; /* dynamic viewport height, where supported */
}
.price {
color: #b24a1a; /* every browser */
color: oklch(55% 0.16 40); /* wide-gamut color */
}
A browser that understands 100dvh uses the second declaration, because it comes later. One that doesn't ignores it and keeps the first. This works for any value a browser may not recognize. It doesn't work when the newer value comes through var(): in color: #b24a1a; color: var(--brand);, the browser keeps the second declaration because it can't check var() while parsing. If --brand turns out to be unusable, the property behaves as unset, and the fallback is already gone (article 3). Put the fallback inside var() instead, as in var(--brand, #b24a1a), or use @supports. It also doesn't work for values a browser accepts but handles differently, or for whole layouts that need several properties to change together. For those, use @supports.
Feature queries with @supports
An @supports rule applies its contents only if the browser supports a declaration:
@supports (display: grid) {
.book-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
}
The condition is a declaration in parentheses. The browser checks whether it parses that property with that value. It doesn't check whether the feature works well, only whether the browser accepts the syntax.
Conditions can be combined:
@supports (position-anchor: --menu) and (position-area: bottom) { ... } /* both */
@supports (aspect-ratio: 1) or (padding-top: 100%) { ... } /* either */
@supports not (container-type: inline-size) { ... } /* lacks it */
When you mix and and or, add parentheses, as in (a) and ((b) or (c)), since CSS doesn't let you mix them without grouping.
Testing selectors and fonts
@supports can test more than declarations:
-
selector()tests whether the browser understands a selector. It's how you check for a pseudo-class such as:has()before relying on it:css@supports selector(:has(a)) { .card:has(img) { grid-template-rows: auto 1fr; } } -
font-tech()andfont-format()test font capabilities, such as color fonts or variable fonts:@supports font-tech(color-COLRv1) { ... }(article 80).
A complete example
Here a list of books is laid out as a grid with a card style. The baseline is a simple stacked list that works everywhere. Browsers with grid support get columns, and browsers that support :has() give cards with a cover image a highlighted border:
.books { list-style: none; padding: 0; margin: 0; }
.books li { border: 1px solid #ccc; padding: 0.75rem; margin-bottom: 0.75rem; border-radius: 6px; }
.books .cover { display: block; height: 3rem; background: #e2d4bd; margin-bottom: 0.5rem; }
@supports (display: grid) {
.books {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
gap: 0.75rem;
}
.books li { margin-bottom: 0; }
}
@supports selector(:has(a)) {
.books li:has(.cover) { border-color: #8a3b12; border-width: 2px; }
}
Notice that the baseline styles sit outside the @supports rules, and the enhanced rules undo what they don't need, such as the margin-bottom that gap replaces. Edit display: grid in the condition to display: grrid to see what a browser without grid would show.

Every panel is usable. Each passing test adds polish, and a failing test only removes that one improvement.
@supports not for fallbacks
Sometimes it's clearer to write the modern version as the main style and put the fallback in a not block:
.tooltip {
position: absolute;
position-anchor: --help;
position-area: top;
}
@supports not (position-area: top) {
.tooltip { position: static; margin-top: 0.25rem; } /* show it below, in flow */
}
Either way works. Choose the one that keeps the modern code readable and the fallback contained.
The limits of @supports
- It tests parsing, not correctness. A browser can accept a property and still have bugs, or support only some values. Test the specific value you rely on:
(display: grid)says nothing aboutsubgrid, so test(grid-template-columns: subgrid)for that. - Everything inside must still parse. Rules inside an
@supportsblock that the browser can't parse are still dropped, as usual. - Testing at-rules is new.
@supports at-rule(@container)works in Chrome 148 and Firefox 157 and later, but not yet in a stable Safari, and older browsers treat the unknown test as false. Until it's Baseline, test a property that comes with the at-rule instead, such as(container-type: inline-size)for container queries or(view-transition-name: none)for view transitions. - Custom properties always pass.
@supports (--theme: dark)is true in every browser that supports custom properties, because any value is valid for them, so it can't detect anything else. - Very old browsers ignore
@supportsentirely, along with everything inside it. That suits enhancements, which these browsers shouldn't get anyway.
Forgiving selectors
As article 3 explained, a selector list with one unsupported selector drops the whole rule. Grouping a new pseudo-class with old selectors is therefore risky:
/* In a browser without :user-invalid, this whole rule is dropped, :invalid included */
input:invalid, input:user-invalid { border-color: #b3261e; }
Three ways around it:
- Separate rules, so each can fail on its own.
:is()or:where(), whose selector lists are forgiving: invalid selectors inside them are skipped, and the rest still match:input:is(:invalid, :user-invalid) { ... }. (The selector list inside:has()is not forgiving.)@supports selector(...)around the rule that uses the new selector.

Only the grouped list on the left loses its :invalid style. :is() skips the unknown part, and separate rules fail one at a time.
Choosing a support target
How far back to support is a project decision, not a technical one. Common approaches:
- Baseline targets. Many teams say "we use Baseline widely available features freely, newly available features with fallbacks, and limited ones only as enhancements." Some pick a Baseline year, such as "Baseline 2024", meaning every feature that became newly available by the end of 2024.
- Analytics. Look at which browsers and versions your real visitors use. An internal tool used only on company laptops has different needs from a public government site.
- Browserslist. Build tools such as Autoprefixer, Lightning CSS and Babel read a shared list of browser targets, such as
> 0.5%, last 2 versions, not deadorbaseline widely available, from your project's configuration, and add prefixes or transform syntax to match.
To try features that haven't shipped yet, use a preview browser: Chrome Canary (or chrome://flags and Experimental Web Platform features in regular Chrome), Firefox Nightly, or Safari Technology Preview. Never rely on a flag in production: your visitors won't have it turned on.
Whatever the target, test the fallback path. Browser DevTools can't switch off individual CSS features, so check in an older browser, or temporarily break the @supports condition to see what the fallback looks like.
What's current
@supports selector()works in every current browser, and has been Baseline widely available since 2023.@supports font-tech()andfont-format()work in Chromium and Firefox, and in Safari since version 17.at-rule(), for testing at-rules such as@supports at-rule(@starting-style), shipped in Chrome 148 (May 2026) and Firefox 157 (September 2026). Safari support is in beta, so it isn't Baseline yet.@import ... supports()can apply the same feature test to a whole stylesheet (article 2).
Common questions
Is progressive enhancement the same as graceful degradation?
They lead to similar results from opposite directions. Graceful degradation starts with the full modern design and then patches older browsers. Progressive enhancement starts with a version that works everywhere and adds features on top. In CSS, the progressive approach is usually less work, because the cascade and @supports are designed for it.
Why use @supports if fallbacks in the cascade already work?
Cascade fallbacks handle one value at a time. When an enhancement needs several properties to change together, such as switching to a grid layout and removing margins, or when the fallback must undo something, a feature query keeps all the related changes together and applies them only when they'll work.
@supports (display: grid) is true, but my subgrid layout is broken. Why?
The query tested only display: grid. Subgrid is a separate feature that came years later. Test exactly what you use: @supports (grid-template-columns: subgrid).
Can I detect CSS support from JavaScript?
Yes: CSS.supports("position-area", "top") or CSS.supports("selector(:has(a))") returns true or false, with the same rules as @supports. In CSS itself, prefer @supports, which needs no script.
Should I still support Internet Explorer? Microsoft ended support for Internet Explorer in 2022, and its share of users is negligible. Unless you have a specific contract or audience that requires it, don't spend effort on it. Older versions of evergreen browsers are a more realistic concern, such as Safari on iPhones that haven't been updated.
Summary
- Build a version that works everywhere, then add enhancements that browsers apply only when they support them.
- For a single value, write the fallback declaration first and the modern one after it.
@supports (property: value)applies rules only if the browser parses that declaration, and supportsand,or,not,selector()and font tests.@supportschecks syntax, not correctness, so test the exact value or selector you rely on.- Don't group new selectors with old ones in a plain list. Use separate rules,
:is()/:where(), or@supports selector(). - Choose a support target from your audience, often expressed as a Baseline level or a Browserslist query, and test the fallback.
Practice questions
Rewrite this rule so that browsers without :focus-visible still show focus styles on links.
a:focus, a:focus-visible { outline: 3px solid #8a3b12; }
Answer
Split it into two rules, so an unsupported selector can't drop the other one:
a:focus { outline: 3px solid #8a3b12; }
a:focus-visible { outline: 3px solid #8a3b12; }
Or use a forgiving list: a:is(:focus, :focus-visible) { ... }. (In current browsers, a common pattern is to style :focus-visible and remove the outline only for :focus:not(:focus-visible), covered in article 42.)
What does a browser that doesn't support dvh do with this rule, and what does one that does support it do?
.panel { height: 100dvh; height: 100vh; }
Answer
Both end up with 100vh. A browser without dvh drops the first declaration. A browser with dvh accepts both, and the later one wins. To enhance, the order must be reversed: height: 100vh; height: 100dvh;.
Which @supports condition would you use before relying on container queries, and why not at-rule(@container)?
Answer
@supports (container-type: inline-size). @supports at-rule(@container) exists, but isn't in every browser yet, so a browser without it would wrongly report no support. container-type is part of the same feature, so a browser that parses it also supports @container size queries.
A designer wants a masonry layout, which only one browser supports. What should the CSS look like so other browsers still show something reasonable?
Answer
Write a regular grid (or columns) as the baseline layout, which every browser supports, and add the masonry layout inside @supports with the masonry display value (article 72). Browsers without it keep the regular grid, with uneven gaps under shorter items but all content readable.
Review quiz
Test yourself on Part 1 with the CSS Part 1 review quiz.
Previous: Elements and Boxes: Block, Inline, Replaced Elements and the display Property
Next: Basic Selectors: Type, Class, ID, Universal and Grouping

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.