Adjacent Content
<div class="bob">
<label>Wally</label>
<span>Mary</span>
</div>
<div class="bob">
<label>Tom</label>
<span>Mary</span>
</div>
Click to copy
Sometimes you might have a page where you need to match on two elements that are next to each other. See the code below.
This selector would target the 2nd div.
.bob:has(label:contains("Tom") + span:contains("Mary"))
Click to copy
0 Comments
Add your comment