CSS :not() Pseudo-class
Example
Set a text color for all elements that are not <p> elements:
:not(p)
{
color:
red;
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The :not()
pseudo-class
matches any element that is NOT the specified element/selector.
Version: | CSS3 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the pseudo-class.
Pseudo-class | |||||
---|---|---|---|---|---|
:not() | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS Syntax
:not(selector) {
css declarations;
}
More Examples
Example
More examples of using not():
.special {
border: 2px solid maroon;
}
p:not(.special) {
color: green;
}
body :not(p) {
text-decoration: underline;
}
body :not(div):not(.special) {
font-weight: bold;
}
Try it Yourself »