เลือกองค์ประกอบลำดับที่ n นับจากลูกสุดท้าย
ใช้ :nth-last-child(n) เพื่อเลือกองค์ประกอบที่เป็นลูกลำดับที่ n ของพาเรนต์ โดยนับจากท้ายสุด
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-child(4) {
background: blue;
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>