Hide empty elements

Angelos Chalaris · CSS, Visual · Nov 18, 2022

Hides elements with no content.

  • Use the :empty pseudo-class to select elements with no content.
Preview

Lorem ipsum dolor sit amet.

<p>Lorem ipsum dolor sit amet. <button></button></p>
:empty {
  display: none;
}

Recommended snippets