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