Is there a CSS selector that can target an element, like <p>
, with only a specified child element, such as <a>
, within it and nothing else? For instance:
<p><a>Some text</a></p>
. I want to avoid selecting elements like <p>Some other text<a>Some text</a></p>
, where content exists outside the <a>
tag.
I experimented with the CSS selector p:has(a)
, but it matches both scenarios. Is there a way to exclusively target the first case while excluding the undesired second one? Your help would be greatly appreciated.
To provide context, I am utilizing Soup Sieve's collection of CSS selectors.