Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <style> /* If there are at least three list items, style them all */ li:nth-last-child(n+3), li:nth-last-child(n+3) ~ li { color: #8EBF41; } </style> </head> <body> <h2>:nth-last-child selector example</h2> <ol> <li>List Item One</li> <li>List Item Two</li> </ol> <ol> <li>List Item One</li> <li>List Item Two</li> <li>List Item Three</li> <li>List Item Four</li> <li>List Item Five</li> <li>List Item Six</li> </ol> </body> </html>