:not() - Selector CSS
Summary of characteristics of the :not() selector
Description of the :not() pseudo-class.
The pseudo-class :not() provides the logical negation functionality. One or more selectors are specified within the parentheses.
:not() targets all elements that are NOT targeted by the selectors listed in the parentheses.
Any combination of selectors can be indicated within the parentheses, except for some few pseudo-elements.
:not(::first-letter) is therefore invalid.
The selector list is not "forgiving," which means that a syntax error on any one of the selectors invalidates the entire list. This behavior is therefore
opposite to that of the pseudo-classes :is() or 
:where() , which also accept a list of selectors but are forgiving.

Note: the :not(*) selector doesn't target anything at all.
Below, the yellow background was applied using the selector td:not(:first-child), which translates to
"all td cells that are not the first ones (in their row)".
Similarly, the border of the header cells (morning / afternoon) was applied with the selector th:not(:first-child).
| Matin | Après-midi | |
|---|---|---|
| Lundi | ||
| Mardi | ||
| Mercredi | ||
| Jeudi | ||
| Vendredi |
Specificity calculation.
The priority of the pseudo-class :not() is the same as that of the most specific selector listed.
Example: the pseudo-class
:not(#id, .class) has the priority of #id.
Tip: :not() can be used to increase the priority of a selector.
Example: we want to override an existing rule on #edito. ID selectors already have a very high priority (100), so the
remaining option is to use !important, but this has drawbacks (see the page on Priorities).
You can also construct a selector like #edito:not(#bidon), which has a priority of 200, thus higher than a simple ID selector.
Example of use of the pseudo-class :not().
The inactive input areas of the form below are grayed out (reduced opacity). This was easily achieved using the :not(:focus) selector.
Browser compatibility with :not().
Initially, :not() only accepted a single selector in the parentheses (level 3 of the W3C specification).
Level 4 of the specification specifies that it can be a list of selectors. Even this last option is relatively well supported by current browsers.
:not() pseudo-class, which targets elements that do not match a certain selector or combination of selectors.:not() pseudo-class with a list of selectors, in accordance with the level 4 specification.:not()pseudo-class
:not()pseudo-class
Selectors list
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Samsung Internet

Opéra

Safari sur IOS

Edge

Firefox

Chrome

Androïd Brower

KaiOS Browser

Chrome pour Androïd

Firefox pour Androïd

Opéra mini
Historic of the :not() pseudo-class.
-
Selectors Level 3
Definition of the pseudo-class:not()which accepts a single selector inside the parentheses.August 03, 1999Working Draft.November 13, 2001Candidate Recommendation.December 15, 2009Proposed for recommendation.September 29, 2011Recommendation . -
Selectors Level 4
Extension of the pseudo-class:not(): it now accepts a combination of selectors within its parentheses.September 29, 2011Working Draft.
See also: other conditional pseudo-classes.






