Target empty elements using the :empty pseudo-class

Damon Bauer
InstructorDamon Bauer

Share this video with your friends

Send Tweet

You can target an element that has no child elements by using the :empty pseudo-class. With browser support down to IE9, it's solid, easy way to select empty elements without any additional markup.

Be aware that whitespace is considered a "child", so :empty will not work if the element has no children, but has space between the opening and closing tags.

Andreas Klein
Andreas Klein
~ 4 years ago

Usually egghead courses have great sound. But this and also Prof. Frisby's are absolutely awful. What is wrong with that?

Daniel Yim
Daniel Yim
~ 3 years ago

Agreed. The sound quality is awful on this course.