CSS :first-of-type Pseudo-class

Definition and Usage

CSS :first-of-type Pseudo-classes are used to select the first element of a specified type among a group of sibling elements.

Example

Select and set the style of the first <p> element in a group of sibling elements:

p:first-of-type {
  background-color: yellow;
}

Try It Yourself

CSS Syntax

:first-of-type {
  css declarations;
}

Technical Details

Version: CSS3

Browser Support

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

Chrome Edge Firefox Safari Opera
4.0 9.0 3.5 3.2 9.6