It's 2022 and :only-child isn't aware of text nodes?

I'm trying to select an image that is the only direct descender of an element, with no text node siblings, e.g.:

<div><img/></div>

Not

<div>Hello<img/>World</div>

div img:only-child will select this img in both cases, as will div img:first-child and div img:last-child

Am I missing something?

@omgmog I never stumble on a case like this, probably because I have a compulsion not to leave a text node untagged. In your second example I would have had:

<div><span>Hello</span><img/><span>World</span></div>

And, off-topic: do we have markdown in Mastodon? I had to refrain from wrapping the above code within ``

Follow

@m2m I think not. I've also been resisting the compulsion to wrap `code` with backticks! 😅

Sign in to participate in the conversation
 Indieweb.Social

INDIEWEB.SOCIAL is an instance focused on the #Openeb, #Indieweb, #Fediverse, #Mastodon #Selfsovereign #identity (#SSI), #Humanetech and #Calm technologies evolution.