Quick Hit #34: Comments Don't Break :empty

Kevin Powell surfaces a detail worth keeping in mind: the :empty pseudo-class treats comments as empty content. An element containing only an HTML comment still matches :empty.

In practice, that means a div holding nothing but <!-- comment --> counts as empty for selector purposes.

CSS-Tricks star logo