:nth-last-of-type(n) सेलेक्टर का उपयोग
:nth-last-of-type(n) सेलेक्टर पैरेंट के अंदर अंतिम से गिनती करके अपने टाइप के nth एलिमेंट को सिलेक्ट करता है।
उदाहरण
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-of-type(2) {
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>
</body>
</html>
5 पैराग्राफ हैं, अंतिम से दूसरा = 4th पैराग्राफ नीला/सफेद होगा।