Comments, processing instructions, and CSS content do not affect whether an element is considered empty.
2025-04-12
Written by: tdtc
<style>
.box {
background-color: lightgreen;
height: 90px;
width: 90px;
}
.box:empty {
background-color: red;
}
</style>
<h1>Demo of :empty</h1>
<div class="box"></div><br>
<div class="box">I will be lightgreen.</div><br>
<div class="box"><!-- I will be salmon --></div><br>
<div class="box"> <!-- I will be lightgreen --> </div>