CSS :only-of-type 선택기를 사용하여 부모의 유일한
요소인 모든
요소의 스타일을 지정합니다.
예시
다음 코드를 실행하여 :only-of-type 선택기를 구현할 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<style>
p:only-of-type {
background: orange;
color: white;
}
</style>
</head>
<body>
<div>
<p>This is demo text 1.</p>
</div>
<div>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
</div>
</body>
</html>