Back to the index.

The :empty pseudo-class selects empty elements, elements without any content.

div:empty {
	background-color: #000000;
	color: #ffffff;

Above this paragraph you see (or don't see) an empty div. I gave it a height so you can see its background color (or lack thereof).

Dynamic content

When we add content to an empty element, it isn't empty any more and the styles should be removed.

Create content Remove content