CSS Portal

:is() CSS Pseudo Class

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The :is() pseudo-class in CSS is a functional pseudo-class designed to simplify writing complex selectors by allowing you to group multiple selectors into a single, concise expression. Essentially, :is() takes a comma-separated list of selectors as its argument and matches any element that fits any one of those selectors. This is especially useful for reducing repetition in CSS rules, making your stylesheets cleaner, more maintainable, and easier to read.

For example, without :is(), you might write multiple selectors like this:

h1.title,
h2.title,
h3.title {
    color: blue;
}

With :is(), this can be simplified:

:is(h1, h2, h3).title {
    color: blue;
}

Here, :is() matches any h1, h2, or h3 element that has the class title, applying the same style without duplicating the selector.

Another powerful aspect of :is() is its ability to combine complex selectors, such as pseudo-classes or combinators:

:is(article, section) p:first-child {
    margin-top: 0;
}

In this example, any first p inside either an article or section will have its top margin removed. This approach avoids repeating pseudo-classes for each parent element.

It’s important to note that :is() has a specificity rule: the specificity of the selector inside :is() does not add to the specificity of the overall rule. The specificity is only determined by the most specific simple selector inside the :is(). This can be useful for preventing overly specific selectors from unintentionally overriding other styles.

In addition, :is() can be combined with other pseudo-classes like :nth-child() or :not() to create highly targeted styles:

:is(li:first-child, li:last-child) {
    font-weight: bold;
}

Here, the first and last li elements in any list are bolded, all within a single rule.

Overall, :is() is a modern CSS tool for making selector logic shorter, more readable, and easier to maintain, especially when dealing with complex structures or repeated patterns.

Syntax

:is(<forgiving-selector-list>) {
  /* ... */
}

Example

<body>

<header>
<h1>Welcome Site</h1>
<a href="#">Header Link</a>
</header>

<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>

<main>
<p>This is the main content. <a href="#">This link stays default.</a></p>
</main>

<footer>
<a href="#">Privacy Policy</a>
<a href="#">Contact Us</a>
</footer>

</body>
/* Target links inside header, nav, or footer only */
:is(header, nav, footer) a {
color: #2e7d32; /* Green */
text-decoration: none;
font-weight: bold;
margin-right: 15px;
}

/* Add a hover effect to those same specific links */
:is(header, nav, footer) a:hover {
color: #1565c0; /* Blue */
text-decoration: underline;
}

/* Comparison: The "main" link remains the default browser blue
because it wasn't included in the :is() list. */

Browser Support

The following information will show you the current browser support for the CSS :is() pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS psuedo class.

This psuedo class is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 31st December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!