CSS :is() Pseudo-Class

Beginner
6 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The :is() pseudo-class accepts a forgiving selector list and matches an element if that element matches any selector in the list. It removes repeated selector prefixes and makes long alternatives easier to read.

Baseline · Widely available.

Its specificity equals the most specific selector in its argument list. Use :where() when you need the same grouping with zero specificity.

CSS Syntax

syntax.css
:is(<forgiving-selector-list>){ … }

Selector Forms

FormDescriptionTry it
:is(h1, h2, h3)Match any listed headingTry it
article :is(p, li)Match paragraphs or list items inside articlesTry it
:is(header, main, footer) aShare a descendant pathTry it
:is(.card, #featured)Specificity follows the most specific argumentTry it

How to Use :is()

  1. Choose the element or scope you want to match.
  2. Write the selector using :is(<forgiving-selector-list>).
  3. Add declarations that communicate the state or grouping clearly.
  4. Test the rule with matching and non-matching markup.
PieceRequired?Role
Base selectorOptionalLimits which elements are candidates
:is()YesApplies this selector's matching behavior
Declaration blockYesDefines the styles for matching elements

Live Preview

Use the controls in the editable examples to observe when :is() matches.

:is() preview

Rule: :is(h1, h2, h3)

All three heading types share one declaration block.

Open live editor

CSS Examples

Each example isolates one practical :is() pattern.

Example 1 — Group Headings

All three heading types share one declaration block.

CSS
<style>
  :is(h1, h2, h3) {
    color: #0f766e;
  }
</style>

<h1>Title</h1><h2>Section</h2><p>Paragraph</p>
Try It Yourself

How It Works

  1. The browser evaluates :is(h1, h2, h3) against the document.
  2. Only elements satisfying that selector receive the declarations.
  3. The rule changes the visible state without changing the HTML structure.
  4. Open the editor to test the selector with different markup.

Example 2 — Shorten Descendant Selectors

The article prefix is written once while both descendant types match.

CSS
<style>
  article :is(p, li) {
    line-height: 1.7;
  }
</style>

<article><p>Intro</p><ul><li>Item</li></ul></article>
Try It Yourself

How It Works

  1. The browser evaluates article :is(p, li) against the document.
  2. Only elements satisfying that selector receive the declarations.
  3. The rule changes the visible state without changing the HTML structure.
  4. Open the editor to test the selector with different markup.

Example 3 — Group States

The button shares feedback across hover and visible focus states.

CSS
<style>
  button:is(:hover, :focus-visible) {
    background: #0f766e;
      color: white;
  }
</style>

<button type="button">Interact</button>
Try It Yourself

How It Works

  1. The browser evaluates button:is(:hover, :focus-visible) against the document.
  2. Only elements satisfying that selector receive the declarations.
  3. The rule changes the visible state without changing the HTML structure.
  4. Open the editor to test the selector with different markup.

Edge Cases & Pitfalls

Check browser behavior, specificity, and accessibility before shipping.

specificity

Know what contributes weight

:is() takes the specificity of its most specific argument.

support

Test target browsers

Use a sensible fallback when older browser support matters.

scope

Keep the selector intentional

Add a base selector or component scope when a page-wide match would be too broad.

Browser Support

:is() is a browser CSS selector; server runtimes do not evaluate it.

✓ Baseline · Widely available

:is()

Chrome 88+, Edge 88+, Firefox 78+, Safari 14+.

96% Modern browsers
Google Chrome Supported
Full support
Mozilla Firefox Supported
Full support
Apple Safari Supported
Full support
Microsoft Edge Supported
Full support
Opera Supported
Full support
Samsung Internet Supported
Full support
:is() Widely supported

Bottom line: Safe for modern production sites. Test the interaction and cascade in the browsers your audience uses.

Key Takeaways

  • Purpose: accepts a forgiving selector list and matches an element if that element matches any selector in the list. It removes repeated selector prefixes and makes long alternatives easier to read.
  • Syntax: :is(<forgiving-selector-list>)
  • Practice: keep selectors scoped and easy to override.
  • Testing: verify both matching and non-matching states.

One line: Its specificity equals the most specific selector in its argument list. Use :where() when you need the same grouping with zero specificity.

Frequently Asked Questions

It matches an element when that element matches any selector in its comma-separated argument list.
It can factor out repeated selector paths, making complex selectors shorter and easier to maintain.
If one argument is unsupported or invalid, browsers can ignore that argument while retaining valid alternatives.
Its specificity is replaced by the specificity of the most specific selector in its argument list.
They match the same way, but :where() always contributes zero specificity while :is() keeps argument specificity.
Pseudo-elements are generally not valid inside :is(); keep the pseudo-element outside the functional pseudo-class.

Next: :where() Pseudo-Class

Continue through the CSS tutorial reference.

:where() Pseudo-Class tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful