h1:not(small)
Your selector h1:not(small)does not work because it says this:
Target all elements h1that are not elements small.
This is the same as the selector h1.
h1 :not(small)
You would be closer to h1 :not(small), which says:
Target all descendants of elements h1except small.
Boom! Exactly what you want.
, (.. ) . CSS.
h1 :not(small) {
color: orange;
}
<h1>This text is contained directly inside the container. It is not selectable by CSS. It is an anonymous element. <small>This text is inside a small element</small></h1>
<hr>
<h1><span>This text is contained in a span. It is selectable by CSS</span> <small>This text is inside a small element</small></h1>
CSS
small, h1.
CSS.
:
:
h1 {
color: orange;
}
h1 > small {
color: black;
}
<h1>I want to select this text with a css selector <small>but not this text</small></h1>