CSS :empty 선택기를 사용하여 CSS로 자식이 없는 모든
요소의 스타일을 지정합니다. 다음 코드를 실행하여 :empty 선택기를 구현할 수 있습니다. −
예시
<!DOCTYPE html>
<html>
<head>
<style>
p.demo {
width: 300px;
height: 20px;
background: gray;
}
p:empty {
width: 150px;
height: 20px;
background: orange;
}
</style>
</head>
<body>
<p class = "demo">This is demo text. Below is empty text.</p>
<p></p>
</body>
</html>