'Select specific child TAG but only if parent has no other children or text
I would like to use a CSS selector to select a specific child TAG but only if parent has no other children or text.
In this specific case the <a>
tag that needs to be selected is wrapped in a <p>
tag.
I'm looking for a CSS-only solution (I'm curious to know if it's actually possible)
<p><a>This is selected</a></p> // selected
<p><a>This is NOT selected</a><span>other children</span></p> // NOT selected
<p><a>This is NOT selected</a>Other text</p> // NOT selected
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|