From the course: Cutting-Edge CSS

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

The difference between :is and :where

The difference between :is and :where - CSS Tutorial

From the course: Cutting-Edge CSS

The difference between :is and :where

(soft music) - CSS has some very interesting pseudo class functions that allow us to both simplify and make more advanced queries for elements. Two of these are, is and where, and at first glance they seem weirdly similar. So let's take a closer look at what makes them different. Both is and where take a selector list and selects any element matching any of the selectors in that list. This is useful if for example you have several elements with the same class and you want to target a subgroup of them. So instead of saying class LI, class P, class button, you would say, class is LI, P, button and you get the same result. Now here's the thing, swap out is for where in this example, and you still get the same results. So what is the difference? It's in the specificity of this pseudo class. Let's say we have two buttons, styled with a button selector to have a background color yellow. Now we target one using is and one…

Contents