:not()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The :not() CSS pseudo-class represents elements that do not match a list of selectors. Since it prevents specific items from being selected, it is known as the negation pseudo-class.

Try it

p:not(.irrelevant) {
  font-weight: bold;
}

p > strong,
p > b.important {
  color: crimson;
}

p > :not(strong, b.important) {
  color: darkmagenta;
}

Mars is one of the most Earth-like planets. Mars day is almost the same as an Earth day, only 37 minutes longer.

NASA's Jet Momentum Propulsion Laboratory is designing mission concepts to survive the Venus extreme temperatures and atmospheric pressure.

The :not() pseudo-class has a number of quirks, tricks, and unexpected results that you should be aware of before using it.

Syntax

The :not() pseudo-class requires a selector list, a comma-separated list of one or more selectors, as its argument. The list must not contain a pseudo-element, but any other simple, compound, and complex selectors are allowed.

css
:not() {
  /* ... */
}

Description

There are several unusual effects and outcomes when using :not() that you should keep in mind when using it: