How can I select an element, say <p>
, that only contains another element, say <a>
, inside it, and nothing else, like this: <p><a>Some text</a></p>
? In contrast, I don't want to select things like <p>Some other text<a>Some text</a></p>
, since there are stuff outside the <a>
element.
I tried the CSS selector p:has(a)
, but this selects both of the cases above. Is there a CSS selector that only selects the first case and not the undesirable second case? Thank you.
For reference, I'm using Soup Sieve's CSS selectors.