CSS :last-of-type Pseudo-class

Definition and Usage

CSS :last-of-type Pseudo-classes are used to match any element that is the last child of its parent element among elements of the same type.

Tip:This is similar to :nth-last-of-type(1) Same.

Example

Specify the background color for the last <p> element and the last <li> element of its parent element:

p:last-of-type {
  background-color: yellow;
}
li:last-of-type {
  background-color: yellow;
}

Try it yourself

CSS Syntax

:last-of-type {
  css declarations;
}

Technical Details

Version: CSS3

Browser Support

The numbers in the table specify the first browser version to fully support this pseudo-class.

Chrome Edge Firefox Safari Opera
4.0 9.0 3.5 3.2 9.6

Páginas relacionadas

Referencia:Pseudo-clase :last-child de CSS