Select the second last <p> element within its parent counting. - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-last-of-type

Description

Select the second last <p> element within its parent counting.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-of-type(2) {
    background: red;
}
</style><!-- ww w  .j a  v  a2  s.  c om-->
</head>
<body>

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

</body>
</html>

Related Tutorials