Open In App

What is the use of the :not() pseudo-Class in CSS ?

The :not() pseudo-class in CSS is used to select elements that do not match a specified selector. It provides a way to exclude certain elements from a set of selected elements, offering flexibility in styling and targeting specific elements within a document.

Syntax

/* Selecting all paragraphs that are not inside a div */
p:not(div p) {
/* styles */
}

/* Selecting all list items that are not the first child */
li:not(:first-child) {
/* styles */
}

Features

Article Tags :