:is
Widely availableSince 202197% of users
Matches any selector in its argument list. Useful for grouping related selectors.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since January 2021. Widely available since July 2023.
The old way and the modern waySee the snippet: Grouping selectors without repetition →
Old way 4 lines
.card h1, .card h2, .card h3, .card h4 {
margin-bottom: 0.5em;
}
/* Same prefix repeated for every selector */Modern 3 lines
.card :is(h1, h2, h3, h4) {
margin-bottom: 0.5em;
}See how modern your own CSS is.Check your CSS →
Quick example
button:is(.primary, .secondary, .tertiary) { padding: 0.5rem 1rem; }Examples
Group related button selectors
button:is(.primary, .secondary, .tertiary) {
padding: 0.5rem 1rem;
border-radius: 4px;
}
/* Without :is, this would need repeated selectors */Use :is() to reduce repetition when styling multiple related button types with the same rules.
Simplify nested selectors
.nav :is(a, button):hover {
background-color: #f0f0f0;
}
/* Matches a or button inside .nav on hover */Combines multiple selectors into one, making CSS more readable than listing each selector separately.
Style form inputs consistently
input:is([type="email"], [type="password"], [type="text"]) {
border: 1px solid #ccc;
padding: 8px;
}Group input types together without repeating the input selector for each type.
Common pitfalls
- :is() takes the highest specificity:is(a, div) has the same specificity as the most specific selector inside it. If one selector inside :is() has high specificity, the entire :is() will too. This can override styles unexpectedly.
- Not all selectors are valid inside :is()Combinators like + (adjacent sibling) and > (child) cannot be used directly inside :is(). Only simple selectors (element, class, attribute, pseudo-class) work.
- Browser support for pseudo-elementsWhile :is() works in all modern browsers, pseudo-elements like ::before cannot be used inside :is(). Use the element selector instead.
:is browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2021.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
88+
78+
14+
88+Mobile
88+Android
79+Android
14+iOS