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 equivalent 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 that fully supports this pseudo-class.

Chrome Edge Firefox Safari Opera
4.0 9.0 3.5 3.2 9.6

Páginas relacionadas

Referência:O pseudo-classe :last-child do CSS