:nth-last-child(n) सेलेक्टर का उपयोग
यह सेलेक्टर पैरेंट के अंतिम चाइल्ड से गिनती करके nth चाइल्ड को सिलेक्ट करता है, चाहे उसका टाइप कुछ भी हो।
उदाहरण
<!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>
इसमें 6 पैराग्राफ हैं, इसलिए 4th लास्ट चाइल्ड = 3rd पैराग्राफ स्टाइल होगा।