CSS :is()

17/07/2026

The CSS :is() pseudo-class is used to group multiple selectors and apply the same styles to any element that matches at least one of them. It helps reduce repetition and makes complex selectors cleaner and easier to maintain.

The modern :is() pseudo-class simplifies complex groupings, improves parser resilience, and changes selector specificity rules.

Eliminate Duplication

Avoid repeating ancestors or sibling pathways. Group complex multi-layered tags in single-line statements to keep stylesheets extremely compact.

Forgiving Selector Lists

Normally, one invalid selector fails an entire styling rule. Inside :is(), the browser skips bad arguments and applies others safely.

Heaviest Specificity Wins

Instead of dynamic elements, the specificity matches the heaviest argument inside the parenthetical list. Learn to predict and prevent cascade bugs.

Before vs After Comparisons

Look at how drastically the nesting structure shrinks when converting standard CSS lists into modern, clean selector lists.

Case Study #1

Drastically Reduce Duplication

Standard nesting often results in long, repetitive selector chains that are annoying to maintain.

Note: By nesting :is(), you can group both the parents and the children, cutting the code size down and making changes a single-line update.

Legacy Repetitive CSS
.main-content h1,
.main-content h2,
.sidebar h1,
.sidebar h2,
.footer h1,
.footer h2 {
  color: #1e293b;
}
Clean CSS using :is()
:is(.main-content, .sidebar, .footer) :is(h1, h2) {
  color: #1e293b;
}
Case Study #2

Forgiving Selector Lists

Normally, browser bugs or unsupported experimental selectors break entire CSS rule blocks. :is() resolves this immediately.

Note: The CSS parser treats lists inside :is() as forgiving, meaning standard entries still style perfectly if vendor prefixes fail.

Legacy Repetitive CSS
/* If browser rejects any-link, */
/* standard hover styling breaks! */
a:hover,
a:-webkit-any-link:hover {
  text-decoration: underline;
}
Clean CSS using :is()
/* Invalid selectors inside list */
/* are skipped without failures. */
:is(a, a:-webkit-any-link):hover {
  text-decoration: underline;
}

Interactive :is() Playground

Write or select selectors to watch elements match in real-time. Toggle between the live styled web interface and raw HTML representation to inspect exactly how selection operates.

Active CSS Selector 0 matched
Equivalent Legacy CSS
header a,
footer a
No :is()

Predefined Selectors

CSS:is()

Master modern CSS grouping

Write compact, forgiving selectors without duplication.

Forgiving Parsing

Invalid selectors inside :is() do not break the whole rule.

Specificity Magic

Takes the specificity of its most specific argument.

Matches evaluate in actual real-time based on selector updates!
0 matched

The “Forgiving” Selector List Feature

Normally, if a single selector in a comma-separated list is invalid or unsupported, the browser **discards the entire CSS rule**. With :is(), lists are parsed leniently, meaning invalid selectors are skipped while valid ones keep working perfectly.

Selector Environment:
Legacy CSS

Standard Comma List

Unforgiving browser parsing

/* One unsupported breaks EVERYTHING */
a:hover,
a:-invalid-vendor-selector {
  color: #3b82f6;
  font-weight: 600;
}
Live Interactive Box
Unstyled Link (Styles Broke)
Entire Block Discarded! Because the browser doesn’t recognize :-invalid-vendor-selector, it drops the entire rule block including a:hover.
Modern CSS

Modern :is() list

Forgiving selector parsing

:is(
  a,
  a:-invalid-vendor-selector
):hover {
  color: #4f46e5;
  font-weight: 600;
}
Live Interactive Box
Styled Link (Styles Applied)
Resilient Styling Active! The browser safely ignores the invalid argument and continues to parse and style a:hover. This is perfect for forward-compatible stylesheets!
Where is this useful?
Historically, when styling custom scrollbars, web extensions, range input thumbs, or vendor hacks, separating rules into multiple blocks was mandatory. With :is(), bundling modern experiments alongside defaults has never been safer.

How :is() Specificity Works

In CSS, the specificity of :is() is not based on what it actually matches. Instead, it gets the specificity of its **most specific (heaviest) argument**, regardless of which selector matches the element.

Select Example Case
Why does this matter?
If you write :is(h1, #featured-id), even when matching a simple <h1> element, it will carry the extreme ID-level specificity of #featured-id!
Interactive Parser
:is(section, #featured) p
Total Specificity Score
Arguments inside :is() Highest Wins
Under the hood calculation

Advertisement
Continue Reading Below