← Back to pseudo-classes

CSS Pseudo-class / Element

:not()

Logical

Selects elements that do not match the given selector.

Syntax

selector:not(excluded) { }

Example

button:not(:disabled) { cursor: pointer; }

Common use cases

  • Styling all items except one specific class
  • Applying hover only to enabled buttons
  • Excluding the last child from a rule

Practical developer insight

:not() accepts any valid selector since CSS4 — you can chain it: :not(.foo):not(.bar). Specificity is determined by its argument.

Related