CSS :first-child 선택기를 사용하여 부모의 첫 번째 자식인 모든
요소의 스타일을 지정합니다.
예시
다음 코드를 실행하여 :first-child 선택기를 구현할 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<style>
p:first-child {
background-color: orange;
}
</style>
</head>
<body>
<h1>Heading</h1>
<p>This is demo text.</p>
<div>
<p>This is demo text, with the first child of its parent div.</p>
<p>This is demo text, but not the first child.</p>
</div>
</body>
</html>