:empty Selector In CSS
Sham Gurav
Posted on April 8, 2022
The :empty CSS pseudo-class represents any element that has no children. Children can be either element nodes or text (including whitespace).
HTML Code -
<div> Hello World !!!</div>
<div> <!-- Empty --> </div>
<div> GoodBye World !!! </div>
CSS Code -
div:empty {
background-color: #ff0000;
}
Output -
💖 💪 🙅 🚩
Sham Gurav
Posted on April 8, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.