@supports and progressive enhancement
How to adopt new CSS safely: a working baseline first, then features layered on with fallbacks, @supports and Baseline data to judge what is safe.
@supports and progressive enhancement
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Browsers ignore CSS they do not understand: an unknown property, value or at-rule is dropped, and the rest of the stylesheet keeps working. That is what makes progressive enhancement possible.
- Declare the safe value first and the newer value after it. A browser that understands the second overrides the first, and one that does not keeps the first.
- `@supports (property: value)` runs a block only when the browser can parse that declaration. `not`, `and` and `or` combine tests, and `@supports selector(:has(a))` tests a selector.
- A selector list with one invalid selector is dropped entirely, unlike inside `:is()` and `:where()`. Put risky selectors in their own rule or behind `@supports selector()`.
- Baseline tells you whether a feature works across the major browsers. Can I Use gives the fuller picture of versions and share of users, and your own analytics decide what your audience needs.
The question every new feature raises
The previous lessons in this group cover features that shipped within the last few years. Each time, someone asks “can I use it yet?”. The honest answer is a more useful question: what happens for the visitor whose browser does not have it?
CSS is unusually good at this. When a browser meets something it does not understand, an unknown property, an unknown value, an unknown at-rule, it throws away just that bit and keeps going. Compare JavaScript, where an unsupported syntax can stop a whole script from loading. That forgiveness is the basis of progressive enhancement: build a version that works everywhere, then add the better version on top.
Fallback by cascade
The simplest tool needs no new syntax:
.hero {
min-height: 100vh; /* works everywhere */
min-height: 100dvh; /* better on mobile, ignored if unknown */
}
.card {
background: #3366cc; /* fallback colour */
background: oklch(55% 0.18 260); /* modern */
}
A browser that cannot parse the second declaration drops it, so the first stands. One that can parse it lets it override the first, because it comes later at the same specificity. This works for values and properties, but not for at-rules or selectors, which need another approach.
@supports for groups of rules
.gallery { display: flex; flex-wrap: wrap; gap: 1rem; }
@supports (display: grid) and (grid-template-columns: subgrid) {
.gallery {
display: grid;
grid-template-columns: subgrid;
}
}
@supports (property: value) matches when the browser can parse that declaration. Combine tests with and, or and not. For selectors there is a separate function, which matters for selectors that would otherwise invalidate a rule:
@supports selector(:has(img)) {
.card:has(img) { display: grid; }
}
In Chrome, an @supports (display: grid) and (not (display: masonry)) block and an @supports selector(:has(a)) block both matched. In JavaScript, CSS.supports('display', 'grid') and CSS.supports('selector(:has(a))') do the same test for script that needs to choose a code path.
The invalid-selector trap
A comma-separated selector list is dropped entirely if any one selector is invalid:
/* In a browser without :has(), this whole rule is thrown away,
including the h1 */
h1, .card:has(img) { margin-block: 1rem; }
I confirmed in Chrome that .i1, :nonexistent { color: red } was ignored in full. The fix is to split the rule, or to wrap the risky one in @supports selector(). Inside :is() and :where() the list is forgiving, which is a good reason to prefer them for lists, but :has() itself is not forgiving.
Baseline, Can I Use, and your audience
Three sources, each answering a different question.
- Baseline (from the web platform community, shown on MDN and web.dev) says a feature is newly available when it works in the latest versions of Chrome, Edge, Firefox and Safari, and widely available after about 30 months more. It is a quick yes or no.
- Can I Use gives the details: which version added support, partial support notes, and global usage.
- Your analytics say which browsers your visitors have. A site for a company’s intranet and a consumer site have different needs.
A feature is safe to use with no fallback when it is widely available and its absence would not break anything. It is worth a fallback when it is newly available, or when it only partly works somewhere. And it is worth considering enhancement-only when the browser support is incomplete, like the anchor positioning in the last lesson.
Design the baseline, not just the fallback
A fallback that is broken is not a fallback. Think of the baseline as a product: if there is no scroll-driven reveal, are the cards still visible? If there is no anchor positioning, can the user still reach the menu? A good habit is to write the enhancement so that its absence leaves the content in its end state:
.card { opacity: 1; }
@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {
.card { animation: fade-up linear both; animation-timeline: view(); }
}
}
Nesting @supports and @media together is fine, and CSS nesting lets you write them inside the rule.
Build tools help, too
A build step can lower syntax for you, such as unnesting rules or adding fallback colours for oklch(). PostCSS and Lightning CSS cover that. They cannot add behaviour a browser lacks, like anchor positioning, though polyfills exist for some features, with costs in size and accuracy. The frontend roadmap covers browser compatibility and polyfills more generally.
What the video covers
Kevin Powell’s “Use new CSS without breaking anything” (November 2026, about 13 minutes) is described as covering what Baseline does and does not tell you, how Can I Use gives a fuller picture, and how progressive enhancement, fallbacks, PostCSS and @supports let you start using newer features today. It also links his videos on interpolate-size: allow-keywords and on using @supports with custom properties. That matches this lesson’s topics. It is only weeks old, so it reflects current tooling. I could not read a transcript, so specific examples are not described.
Where this fits
This lesson closes the modern CSS group, tying together features like nesting, @property and anchor positioning with a way of adopting them. The next group is about the tools around CSS, starting with architecture and BEM.
Check yourself
You want a grid layout but need older browsers to get something readable. How do you structure the CSS?
Write the simple version first (for example block or flex layout), then wrap the grid in `@supports (display: grid)` or rely on the cascade so grid overrides. Browsers that do not know the feature skip the block and keep the baseline. The baseline should be readable on its own, not a broken layout.
Why does `h1, h2:unknown-pseudo { color: red }` fail to colour the `<h1>`?
A selector list is dropped as a whole if any selector in it is invalid, because the browser cannot tell what the author meant. `:is()` and `:where()` are forgiving, but a plain comma list is not. Splitting the risky selector into its own rule, or using `@supports selector(...)`, avoids losing the safe one.
What does `@supports not (display: masonry)` tell you, and what does it not?
It matches when the browser cannot parse `display: masonry` as a declaration. It tests parsing, not whether the feature behaves correctly. A feature can parse but still be partial or buggy, so check Can I Use and test in browsers for important features.
When is `@supports` unnecessary?
When the cascade already handles the fallback. If you write `width: 100%; width: stretch;` there is no need to wrap the second line, because a browser that rejects it keeps the first. Use `@supports` when the enhancement needs several coordinated rules, or when the unsupported behaviour would be worse than the fallback.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.