All about the new :is() and :where() selectors in CSS

Let's take a look at the latest selectors offered by CSS: where and is! These selectors will allow us to reduce our code and select our elements more flexibly.
•
Updated on August 14, 2026
•
4 min read
Believemy logo

Let's discover together the latest selectors introduced by CSS: :where() and :is()! These selectors will allow us to reduce our code and select our elements more flexibly. How does it work? That's everything we'll cover in this article.

 

The Problem with Our Selectors

When coding in the style sheets of our projects, you've surely already encountered results like this:

CSS
.main h1,
.main h2,
.main .leading {
    color: pink;
}

.nav li,
.nav p {
    padding: 15px;
}

This kind of selectors isn't impressive; it allows us to specify multiple elements to select and style using a comma, nothing more, nothing less.

We generally use this kind of code when we want to factorize our code so that we don't have to specify the color for each h1, h2, and each leading class manually, one by one. The problem remains that we have very long code across multiple lines.

Thanks to the introduction of the :is() and :where() selectors, this kind of selectors will now be just memories!

 

The :is() Selector

Think about every moment when you want to apply the same style to multiple elements. With :is(), we can now select all these elements in a shorter, faster, and more intuitive way.

CSS
.main :is(h1, h2, .leading) {
    color: pink;
}

.nav :is(li, p) {
    padding: 15px;
}

Quite simple to use, don't you think?

The :is() selector allows us to select multiple elements to target without having to specify the parent elements each time.

 

The :where() Selector

The :where() selector might... confuse you. And for good reason: it works exactly like the :is() selector and offers more or less the same functionality, but with one key difference.

CSS
.main :where(h1, h2, .leading) {
    color: pink;
}

.nav :where(li, p) {
    padding: 15px;
}

But wait, does it really work the same as :is()?

Well yes, nothing changes except that we use where instead of the word is. At least, in the code. Because behind the scenes... that's another debate!

The :where() selector allows us to select multiple elements to target without having to specify the parent elements each time and without adding specificity to the targeted properties. In other words, a bit deeper without adding specificity to the targeted element.

 

What is Specificity?

Excellent question!

Specificity is a value that tells the browser which property to prioritize.

Here's a small example:

HTML
<div id="text-purple" style="color: pink">Hello Believemy</div>
CSS
.text-red {
    color: red;
}

What color do you think the text will be? Purple or pink? Pink, of course.

But how come your browser chose pink instead of red? The answer is simple: thanks to specificity.

By specifying the style attribute, we have informed our browser that it is a property to prioritize above all others that might—or might not—exist.

Each CSS selector has its own specificity. Thus, if two properties are added to the same element using two different selectors, the one with the higher specificity will always win.

Here is the hierarchy between each type of selector:

  1. Inline styles with the style attribute (1000 specificity points);
  2. An ID (#id) (100 points);
  3. A class (.class), an attribute (input[attribute]), or a pseudo-class (input:hover) (10 specificity points);
  4. An element (input), a pseudo-element (input::before) (1 specificity point).

These specificity points can add up to each other.

Thus, we will have:

  • 2 specificity points for ul li { ... }
  • 14 specificity points for div ul ol li.text-red { ... } (four elements + one class: 4 + 10)

Not to mention !important, which is worth 10,000 specificity points (and allows you to "force" the use of a certain property, hence the interest of the word "important").

If we take the example above, to have the text in red instead of pink, we will need to specify !important:

CSS
.text-red {
    color: red!important;
}

 

Conclusion

The two new selectors: :is() and :where() are very interesting as they allow better targeting of elements and result in cleaner, easier-to-read code.

The only unique difference between these two selectors is that the :where() selector adds no specificity and therefore no specificity points to the targeted elements, whereas :is() uses the specificity of the most specific selector (if you target classes, it will return a specificity of 10, whereas if you target classes and IDs, it will have a specificity of 100).

From now on, you can say that you know everything about :is() and :where(). If you want to learn more about HTML and CSS, we have a comprehensive course dedicated to these two programming languages. Also, feel free to share this article with your network on your social media. Thank you!

Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

The complete Flexbox CSS guide

Are you learning how to use Flexbox? Looking for a way to use Flexbox with CSS? Don't know how Flexbox works? Welcome to the complete Flexbox CSS guide!

December 5, 2024

How can you use CSS variables to make everything more dynamic?

Perhaps you've already had that moment when you wanted to change the main colour of one of your projects? Or perhaps you've already experienced those moments when you go back to retrieve the colours of your site's theme? It's all very time-consuming and impractical. Thanks to CSS variables, this will be a thing of the past! Let's find out how.

December 9, 2024

What's new in Tailwind CSS v4

Tailwind CSS 4 has just been announced. Numerous enhancements have been made to optimize the CSS framework. Let's take a look at what's new in Tailwind CSS v4.

June 25, 2025

The complete guide to underlines (CSS)

All about all... You'll know all about underscores! All right, you recognize the music, don't you? In any case, underlines don't just underline our texts from time to time, they're a real stylization tool, allowing us to add bars below, but also above, in the form of waves, dotted lines, dashes... As you can see, we're going to take a look at all this in this article.

December 6, 2024

Link CSS to HTML: 3 Methods Explained Simply

Learn the 3 methods to link CSS to HTML: external stylesheet, internal style, and inline. Code examples, best practices, and common mistakes to avoid.

March 22, 2026

Tailwind CSS 4.2: All New Features and Improvements

Discover everything new in Tailwind CSS 4.2: new color palettes, logical properties, webpack plugin and more. The complete guide to mastering this update.

May 5, 2026

Syntax highlighting with HTML and CSS

If you have a blog or a portfolio on which you want to present code, whether HTML / JavaScript or CSS code extracts, you have undoubtedly come up against a problem: how do you activate syntax highlighting to make it look as if you had put the code in a code editor? In this article, we'll look at how to do it.

December 9, 2024

The out-of-range selector (for styling when a value is not correct)

Have you always wanted to dynamically check the values entered by your users in a form field without using JavaScript? Here's how to change the style of a field when a number entered by the user is invalid!

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.