I am trying to target the <li>
elements that do not have an immediate parent of <ul>
.
Even after using the selector mentioned above, it doesn't seem to work as expected.
.level1:not(:has(ul)) {
background: red;
}
<ul>
<li class="level1">Link1</li>
<li class="level1">Link2
<ul>
<li>Link2</li>
</ul>
</li>
</ul>