Feature Queries in Depth: @supports, selector() and font-tech()
Progressive enhancement with feature queries: @supports syntax and its parenthesis rules, combining conditions, selector(), font-tech() and font-format(), at-rule(), conditional imports, CSS.supports() in JavaScript, and what a query can't tell you.
kvi5hnuCode Sprout team member6 min readOn this page
New CSS arrives in browsers at different times. A feature query applies rules only if the browser supports something, so you can use a new feature where it exists and keep a working fallback elsewhere. This is progressive enhancement: a solid base for every browser, improved where possible.
Often you don't need a feature query at all. A browser drops declarations it doesn't understand (article 3), so writing the fallback first and the new value second is enough:
.wall {
display: grid; /* every browser */
display: grid-lanes; /* used where supported; dropped elsewhere */
}
Feature queries are for when the fallback and the enhancement need different sets of rules: if a new layout needs other properties changed too, or the fallback must be undone.

The left panel is what a browser without the feature sees: the fallback alone must still be a complete, usable layout.
@supports syntax
@supports (display: grid-lanes) {
.wall { display: grid-lanes; gap: 1rem; }
.wall > * { margin: 0; } /* undo the fallback's spacing */
}
The condition is a declaration in parentheses. A browser supports it if it can parse that property and value.
| Condition | Meaning |
|---|---|
(prop: value) | the declaration is supported |
not (…) | it isn't |
(…) and (…) | both are |
(…) or (…) | either is |
selector(…) | a selector is supported |
font-tech(…), font-format(…) | a font technology or format is supported |
at-rule(@name) | an at-rule is supported (Chrome 148, Firefox 157, Safari 27.3) |
The parenthesis rules
The grammar is strict, and an invalid condition makes the browser drop the whole rule. Tested in Chrome, these are all dropped:
@supports display: grid { … } /* no parentheses */
@supports (display: grid) and (gap: 1px) or (color: red) { … } /* and mixed with or */
@supports (display: grid) and not (display: grid-lanes) { … } /* not after and, ungrouped */
Group to fix them:
@supports (display: grid) { … }
@supports ((display: grid) and (gap: 1px)) or (color: red) { … }
@supports (display: grid) and (not (display: grid-lanes)) { … }
An unknown property, though, is just false: (foo-bar: 1) or (display: grid) is true. And !important is allowed inside the declaration.
Testing "not supported"
not is how you write fallbacks that only old browsers should see:
@supports not (aspect-ratio: 1) {
.thumb { padding-top: 100%; height: 0; } /* the old padding hack */
}
Since browsers that don't support @supports at all are long gone, not queries are reliable.
selector()
selector() tests whether a selector parses, which declarations can't do:
@supports selector(:has(> img)) {
.card:has(> img) { grid-template-rows: 10rem auto; }
}
@supports not selector(:focus-visible) {
.button:focus { outline: 3px solid; }
}
Tested in Chrome: selector(:has(a)) is true, and selector(:has(:has(a))) is false, because :has() can't be nested, so the test reflects real validity, not just whether the name is known. That matters because an unsupported selector in a list drops the whole rule (article 12); :is() and :where() are the exceptions, which are forgiving.
font-tech() and font-format()
These test font support, mostly useful for color and variable fonts:
@supports font-tech(color-COLRv1) {
.emoji-heading { font-family: "Brand Color Emoji", sans-serif; }
}
@supports font-tech(variations) and font-format(woff2) { … }
Technologies include variations, color-COLRv0, color-COLRv1, color-SVG, color-sbix, palettes and features-opentype. In @font-face, the src descriptor's tech() and format() hints do the same job for choosing a file (article 83).
Conditional imports and nesting
@import can take a supports() condition, which loads the file only where the condition is true: Chrome 122, Firefox 115, Safari 17.5.
@import url("lanes.css") supports(display: grid-lanes);
@import url("theme.css") layer(theme) supports(color: oklch(0 0 0)) screen;
@supports can be nested inside rules (article 21) and combined with @media and @container:
.wall {
display: grid;
@supports (display: grid-lanes) {
display: grid-lanes;
}
}
CSS.supports() in JavaScript
CSS.supports('display', 'grid-lanes'); // two-argument form
CSS.supports('(display: grid) and (gap: 1rem)'); // a condition
CSS.supports('selector(:has(a))');
Use it when the behavior, not only the styling, depends on support: for example, only adding JavaScript-driven masonry when grid lanes aren't available. Tested in Chrome: the one-argument form also accepts a declaration without parentheses, CSS.supports('display: grid'), unlike the @supports rule.
What a feature query can't tell you
@supports checks parsing, not whether the feature works well:
- A browser can parse a value but have bugs or a partial implementation. Years ago,
@supports (gap: 1rem)was true in browsers that supportedgapin grid but not in flexbox, so it couldn't detect flex gap. - Values that parse anywhere, like custom properties, are always true:
(--x: anything)is true in every browser. - It can't test for user preferences or the environment; use media queries (article 76) for those.
So write the fallback first, test the enhancement in each browser, and check support data on MDN or caniuse.com rather than relying on the query alone.

The two traps are at the bottom right: a custom property accepts any value and gap parses for every layout, so both are true without telling you anything useful.
body { font: 0.8rem system-ui, sans-serif; margin: 1rem; }
.report { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; }
.report li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 0.6rem; border-radius: 6px; background: #fbe4e1; }
.report li.yes { background: #dff0e5; }
.report code { overflow-wrap: anywhere; }
Open this preview in different browsers to compare: the list is computed live with CSS.supports().
What's current
@supportswith declarations: all browsers for over a decade;selector()since 2021.font-tech()andfont-format(): all browsers since 2023.at-rule(): Chrome 148, Firefox 157, Safari 27.3.@import … supports(): all browsers since 2024.
Common questions
Why is my whole @supports block ignored in every browser?
The condition is probably invalid: missing parentheses, or and and or mixed without grouping.
Do I need @supports to use a new property?
Not if the fallback is just an earlier declaration of the same property. Use it when other rules must change with it.
How do I test for a selector?
@supports selector(:has(a)), or CSS.supports('selector(:has(a))').
Is a true @supports result a guarantee?
No. It means the browser parses the declaration; test that it actually works.
Summary
- Feature queries apply rules only where a feature is supported, for progressive enhancement.
- Conditions need parentheses, and
and,orandnotcan't be mixed without grouping; an invalid condition drops the rule. selector()tests selectors,font-tech()andfont-format()test fonts, andat-rule()tests at-rules.@import … supports()loads a stylesheet conditionally;CSS.supports()tests from JavaScript.- A feature query tests parsing, not quality; keep a fallback and test in real browsers.
Practice questions
Fix this rule so it works.
@supports (display: grid) and not (display: grid-lanes) {
.wall { columns: 3; }
}
Answer
Wrap the not condition in its own parentheses:
@supports (display: grid) and (not (display: grid-lanes)) {
.wall { columns: 3; }
}
When is a feature query unnecessary for adopting a new value?
Answer
When the fallback is the same property with an older value. Write the old declaration first and the new one second: unsupported browsers drop the new one and keep the old.
Write a rule that adds an outline on :focus only in browsers that don't support :focus-visible.
Answer
@supports not selector(:focus-visible) {
.button:focus { outline: 3px solid; }
}
Why can't @supports (gap: 1rem) tell you whether flexbox gap works?
Answer
gap parsed in browsers that only supported it for grid, so the query was true even where flex gap didn't work. Feature queries test parsing, not every context a property applies to.
Previous: Container Style Queries and Scroll-State Queries
Next: Print Styles: @media print, @page, Page Breaks and Margin Boxes

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.