Les pseudo-classes :first-of-type et :last-of-type.
Summary of characteristics of the :first-of-type selector
Description of the pseudo-classes :first-of-type and :last-of-type.
These pseudo-classes let you target the first or last element of a parent, considering only elements of the same type, like just the p tags.
Example of a table with a single row containing th cells and td cells.
Other pseudo-classes related to the order in the source document.
:first-of-type and :last-of-type are part of a series of pseudo-classes that also allow you to target elements based on their position
in the document tree:
Examples with the pseudo-classes :first-of-type and :last-of-type.
In the example below, the first and last elements of each type have been highlighted with a colored border, red for the first elements and blue for the last ones.
p
p
This second example shows how to target only the first and last elements of a given type, here the p elements.
p
p
Browser support (compatibility).
The two pseudo-classes :first-of-type and :last-of-type no longer have any compatibility issues.
:first-of-type pseudo-class, which targets the first element of each type among the children.:last-of-type, which targets the last of each type among an element's children.Notes:
(1) Internet Explorer treats all unknown types, including custom elements, in the same type.
:first-of-typepseudo-class
:last-of-typepseudo-class
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Samsung Internet

Opéra

Safari sur IOS

Firefox

Firefox pour Androïd

Edge

Chrome

Androïd Brower

KaiOS Browser

Chrome pour Androïd

Opéra mini
History of the pseudo-classes :first-of-type and :last-of-type.
-
Selectors Level 3
This document describes the selectors that already exist in CSS1 and CSS2, and further introduces new selectors for CSS3 and other languages that may need them.
Regarding:first-of-typeIntroduction of the pseudo-classes:first-of-typeand:last-of-type.August 03, 1999Working Draft.November 13, 2001Candidate Recommendation.December 15, 2009Proposed for recommendation.September 29, 2011Recommendation . -
Selectors Level 4
This specification module defines new selectors that can be used in CSS.
Regarding:first-of-typeNo changes regarding the pseudo-classes:first-of-typeand:last-of-type.September 29, 2011Working Draft.
See also: DOM-related pseudo-classes.
Several pseudo-classes allow targeting one or more elements based on their location in the DOM. Here's the list:








@scope directive.



