The :last-of-type selector

suggest change

The :last-of-type selects the element that is the last child, of a particular type, of its parent. In the example below, the css selects the last paragraph and the last heading h1.

p:last-of-type { 
  background: #C5CAE9; 
h1:last-of-type { 
  background: #CDDC39; 
<div class="container">
    <p>First paragraph</p>
    <p>Second paragraph</p>
    <p>Last paragraph</p>
    <h1>Heading 1</h1>
    <h2>First heading 2</h2>
    <h2>Last heading 2</h2>


Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents