I have these two markup up patterns:
<h3>
<span>Title</span>
<span></span>
</h3>
and
<h3>
<span>Title</span>
<span><a>link</a><a>link</a></span>
</h3>
I want to target the former but not the latter with CSS and use ::after to insert a visual flourish. I prefer not to use a class. I just can’t seem to get it!
h3>span+span:not(h3>span+span>a)::after {
border: solid 1px transparent;
content: '2199';
display: inline-block;
color: gray;
}
2
Answers
Use
:not(:has(*))
to select an empty element (more detail from my blog: https://css-tip.com/number-elements-has-selector/)You could use
has()
for that: