Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-child(2) {
    background: #ff0000;
}

</style>
</head>
<body>

<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>

<p><b>Note:</b> Internet Explorer 8 and earlier versions do not support the :nth-last-child() selector.</p>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy