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 and is 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 indicate 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

Related Pages

Reference:CSS :last-child Pseudo-class