Max Glenister

Things I've found

Links, videos and the odd note, posted here first and shared to Mastodon. The best of each week ends up in Links Worth a Look on the blog.

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?