CSS Academy · Lesson

:not() :is() and :where()

Exclude elements with :not(), match any of a list with :is(), and use :where() for low specificity.

Lesson 3 of 413 steps

:not() :is() and :where() is a free CSS Academy lesson on CoddyKit. This is lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, and your progress syncs across the web and the CoddyKit app. The CSS Academy course includes 4 lessons in total.

:not() Pseudo-class

:not(selector) selects elements that do not match the given selector. It inverts the selection.

<input type="text" placeholder="Text input (styled)" />
<input type="submit" value="Submit (unstyled)" />

:not() with Multiple Arguments

Modern CSS allows multiple arguments inside :not() — it matches elements that match none of the listed selectors:

<a href="#">Normal link</a> <a href="#" class="active">Active link</a> <a href="#" class="disabled">Disabled link</a>

:not() Specificity

The specificity of :not() is the specificity of its most specific argument. :not(.active) has class-level specificity (0,1,0).

:is() Pseudo-class

:is() matches any element that matches any of a list of selectors. It simplifies grouping and reduces repetition.

<header><h1>Site Title</h1><h2>Subtitle</h2><h3>Tagline</h3></header>

:is() Specificity

:is() takes the specificity of its most specific argument. If the list contains an ID selector, the whole rule has ID specificity.

<div id="header"><h2>Header H2 (crimson via ID)</h2></div>
<div class="card"><h2>Card H2 (crimson via class)</h2></div>

:is() Forgiving Parsing

:is() uses forgiving selector parsing: if any selector in the list is invalid, it is silently ignored and the rest still apply. Regular comma-separated selectors fail entirely if one is invalid.

:where() Pseudo-class

:where() works exactly like :is() but has zero specificity. It is designed for utility classes and reset styles that should be easy to override.

<h1>No top margin</h1><h2>No top margin</h2><h3>No top margin</h3>

:where() for Resets

:where() is ideal for CSS resets and base styles that should never win specificity battles:

<ul><li>Item A</li><li>Item B</li></ul>
<ol><li>Step 1</li><li>Step 2</li></ol>

Comparing Specificity

Summary of specificity behavior:

  • :is() — highest specificity among arguments
  • :where() — always zero specificity
  • :not() — highest specificity among arguments

Chaining :is() and :not()

Combine them for precise, readable selectors:

<nav class="nav"><a href="#">Link</a> <button>Button</button> <a href="#" class="disabled">Disabled Link</a></nav>

Browser Support

:is() and :where() are supported in all modern browsers. :not() with multiple arguments is supported in modern browsers. Avoid in projects requiring IE11 support.

Quick Check

Which pseudo-class has zero specificity regardless of its arguments?

Recap

:not() inverts selection and accepts multiple arguments. :is() matches any of a list with the highest specificity in that list. :where() does the same but with zero specificity — perfect for resets. All three use forgiving parsing, silently ignoring invalid selectors.

Free to start

Learn CSS with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
40
Lessons
159

Frequently Asked Questions

Is the “:not() :is() and :where()” lesson free?

Yes — the full text of “:not() :is() and :where()” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO. The CSS Academy course includes 4 lessons in total.

What will I learn in “:not() :is() and :where()”?

Exclude elements with :not(), match any of a list with :is(), and use :where() for low specificity. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.

How long does the “:not() :is() and :where()” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. :hover :focus :active and :visited
  2. :nth-child and :nth-of-type
  3. :not() :is() and :where()
  4. :checked :disabled and Form State Pseudos
← Back to CSS Academy