Pseudo-class :nth-child(n)
ใช้ :nth-child(n) เลือกองค์ประกอบที่เป็นลูกคนที่ n ของพาเรนต์ (นับทุกชนิด)
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(4) {
background: orange;
color: white;
}
</style>
</head>
<body>
<p>This is demo text 1.</p>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
<p>This is demo text 5.</p>
<p>This is demo text 6.</p>
</body>
</html>