The negation pseudo-class takes as an argument a simple selector list (combinations not allowed). It matches an element which is not represented by the passed argument and this negation may not be nested within itself.
# Syntax
Copy
:not(negation-selector) {
/* declarations */
}
# Example
Copy
a:not([rel="external"]) {
color: red;
}
All links in the example which have no external rel attribute should be colored in red.
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
Yes (2)
Yes (1)
Yes (1)
Yes (12)
Yes (9)
Yes (9.5)
Please wait a moment, the comments start loading now...