Skip to content

is has not if only if its child is

Impressed myself just now by a) trying a main :not(article, figure, img, video, embed, audio, iframe, div, p:has(img:first-child)) selector without looking anything up and b) it actually fucking working.

I love this almost natural language like CSS. (It means select anything within the main element that’s not an article, figure, img, video, embed, audio, iframe, div or – get this – a p whose first child is an img 🤯)