E:nth-last-of-type

Matches an E element, that is the n-th sibling of its type, counting from the last one. (Source: W3C)

HTML:

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

CSS:

  1. p{font-style:normal}
  2. p:nth-last-of-type(2){font-style:italic}

Output:

Lorem ipsum dolor sit amet, consectetur

Lorem ipsum dolor sit amet, consectetur

Lorem ipsum dolor sit amet, consectetur

In the example, the first line of text should be set in italics as it is the second p-element from the bottom in the parent element.