Consider the following example:
:not(p) {
color: red;
}
<div>
Red
</div>
<p>
"p" why red?
</p>
According to MDN docs :not(p)
should select only the elements which are not p
, but in my example it also selects p
, why?
It might be said that :not
is pseudo selector so it must be combined with another selector like .test:not(p)
. Then why does the following work:
body :not(p) {
text-decoration: underline;
}
<div>
Underlined, because I am not "p"
</div>
<p>
test
</p>