:not()
W3C CSS Snapshot 2026
Exclude elements that match a selector or any selector in a list.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
p:not(.notice) | Matches paragraphs that lack the notice class. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>:not()</title>
<style>
p:not(.notice) { color: teal; }
</style>
</head>
<body>
<p class="notice">Registration opens Monday.</p>
<p id="location">Meet in Room 2.</p>
<h2>Workshop</h2>
</body>
</html>
What to expect The room paragraph changes. The notice remains unchanged.