CSS :only-child 선택기를 사용하여 부모의 유일한 자식인 모든
요소의 스타일을 지정합니다.
예시
다음 코드를 실행하여 :only-child 선택기를 구현할 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<style>
p:only-child {
background: orange;
}
</style>
</head>
<body>
<h1>Heading</h1>
<div>
<p>This is a paragraph.</p>
</div>
<div>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</div>
</body>
</html>