← Back to CSS
54

Functional selectors: `:is()`, `:where()`, `:not()` and combined patterns

Learn how to reduce repetition, control specificity and build maintainable selectors with `:is()`, `:where()` and `:not()` in real interface patterns.

📘 Theory

What each functional selector solves

Use each one with intention: group, neutralize specificity or exclude.

`:is()` simplifies repeated selector lists. Instead of writing `header a, main a, footer a`, you can write `:is(header, main, footer) a`.

`:where()` has zero specificity, which makes it ideal for base styles that should never fight with component classes.

`:not()` helps you express exceptions cleanly when you want one general rule except for a few variants.

  • `:is()`: group selectors without repeating long prefixes.
  • `:where()`: write a base that stays easy to override.
  • `:not()`: explicit and maintainable exclusion.

Specificity strategy

Prevent specificity wars at the selector design stage.

1

If a rule is foundational, such as base typography or default spacing, `:where()` is often the safest choice because it does not block future overrides.

2

Reserve `:is()` for grouping equivalent selectors inside components or layout structures.

3

Combine functional selectors with state classes such as `.is-active` or `.is-disabled`, letting the selector reduce structural repetition instead of inflating complexity.

🧪 Learn by doing

Example Demo: group selectors without duplication Refactor repeated selectors with `:is()` and define low-specificity base styles with `:where()`.

🏁 Challenges

Challenge Challenge: exclusion with `:not()` Apply a neutral style to every button except the primary and danger variants.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com