A pseudo-class attached to an element p:not(strong)selects from those elements to which it is attached (here p); and an element is <p>always not an element <strong>; therefore, this selector will always match every element <p>.
, <p> <strong>, , CSS (. "Is CSS?" )
( ) <p> :
<p class="hasStrongDescendant"><strong><strong>Local:</strong><br>
-Brasília/DF </p>
:
p:not(.hasStrongDescendant) {
}
p:not(.hasStrongDescendant) {
color: orange;
}
<p>A paragraph with no child elements</p>
<p class="hasStrongDescendant"><strong>Local:</strong>
<br>-Brasília/DF</p>
Hide result, data-*:
<p data-hasChild="strong"><strong>Local:</strong><br>
-Brasília/DF </p>
:
p:not([data-hasChild="strong"]) {
}
p:not([data-hasChild="strong"]) {
color: #f90;
}
<p>A paragraph with no child elements</p>
<p data-hasChild="strong"><strong>Local:</strong>
<br>-Brasília/DF</p>
Hide result, <p>, <strong>, :
<p>A paragraph with no child elements</p>
<p><strong>Local:</strong>
<br><span>-Brasília/DF</span>
</p>
:
p :not(strong) {
color: #f90;
}
p :not(strong) {
color: #f90;
}
<p>A paragraph with no child elements</p>
<p><strong>Local:</strong>
<br><span>-Brasília/DF</span>
</p>
Hide result, , <strong> ( ):
p {
color: #f90;
}
p strong {
color: #000;
}
p {
color: #f90;
}
p strong {
color: #000;
}
<p>A paragraph with no child elements</p>
<p><strong>Local:</strong>
<br>-Brasília/DF</p>
Hide resultCSS-:
p {
color: #f90;
}
p[data-label]::before {
content: attr(data-label) ': ';
color: #000;
display: block;
font-weight: bold;
}
<p data-label="Local">-Brasília/DF</p>
Hide result: