E:last-child

Matches element E when E is the last child of its parent.

HTML:

  1. <div>
  2. <p>Lorem ipsum dolor sit amet, consectetur</p>
  3. <p>Lorem ipsum dolor sit amet, consectetur</p>
  4. </div>

CSS:

  1. p{font-style:normal}
  2. p:last-child{font-style:italic}

Output:

Lorem ipsum dolor sit amet, consectetur

Lorem ipsum dolor sit amet, consectetur

In the example, the second paragraph should be set in italics.