Abakada: Back to Basics > Language References > CSS Properties > Pseudo-Classes > first-of-type Pseudo-class
Matches the first element of its type among a group of sibling elements.
selector:first-of-type { property: value; }
property |
Any valid CSS property. |
value |
Any of the range of values available to the corresponding property. |
The :first-of-type pseudo-class applies styles to the first element of its type among a group of sibling elements.
The syntax for using the :first-of-type pseudo-class is straightforward. A selector immediately precedes the pseudo-class.
For example, to change the background color of first-of-type elements on a page.
div:first-of-type { background-color: beige }
The following demonstrates use of the :first-of-type pseudo-class in an embedded stylesheet to set the style of first-of-type elements on a page.
:last-of-type :nth-of-type( ) :nth-last-of-type( ) :only-of-type