Dev Helpers

CSS / Selectors and generated content

Show a placeholder for an empty panel

Dev Helpers · November 22, 2025

The empty pseudo-class tests the DOM's contents. A text node introduced by indentation can change whether a placeholder appears.

Worked example

<style>
  .demo:empty::before {
    content: "No results";
    color: #475569;
  }
</style>
<div class="demo"></div>

Implementation notes

A loading container and an empty collection can have identical child counts. Use application state to decide which message is accurate.

Try it yourself

Compare an empty element with one containing whitespace.

Open the CSS example →

Editorial date November 22, 2025 · Published December 6, 2026

Related articles

Fluid width with a maximum

A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.

Square aspect ratio

A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.