:last-child सेलेक्टर का उद्देश्य
:last-child सेलेक्टर पैरेंट के **अंतिम चाइल्ड** एलिमेंट को सिलेक्ट करता है (किसी भी टाइप का)। यदि अंतिम चाइल्ड निर्दिष्ट टाइप का नहीं है, तो कोई मिलान नहीं होता।
उदाहरण
<!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>
यहां सभी चाइल्ड <p> हैं, इसलिए अंतिम वाला स्टाइल होगा। यदि अंतिम चाइल्ड <div> होता, तो कोई <p> स्टाइल नहीं होता।