ในการจัดรูปแบบทุกองค์ประกอบ
ที่เป็นลูกสุดท้ายของพาเรนต์ ให้ใช้ตัวเลือก CSS :last-child คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน :last-child selector
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
p:last-child {
background: orange;
}
</style>
</head>
<body>
<p>This is demo text1.</p>
<p>This is demo text2.</p>
<p>This is demo text3.</p>
</body>
</html> ผลลัพธ์
