:nth-of-type() pseudo-classesBaseline · Widely available
The :nth-of-type() and :nth-last-of-type() CSS functional pseudo-classes match elements based on their position among siblings of the same type. The :first-of-type, :last-of-type, and :only-of-type pseudo-classes match the first, last, and only elements of its type.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.
Browser support
DesktopChrome
1–3Not supported
4+Supportedsince Jan 25, 2010
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–3Not supported
3.5+Supportedsince Jun 30, 2009
Current: 157Safari
1–3Not supported
3.1+Supportedsince Mar 18, 2008
Current: 27MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155Firefox Android
4+Supportedsince Mar 29, 2011
Current: 157Safari iOS
1–1Not supported
2+Supportedsince Jul 11, 2008
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: :first-of-type.
Feature detection
CSS · check before using
@supports selector(:nth-of-type) {
/* styles that use :nth-of-type */
}
/* or in JavaScript */
if (CSS.supports("selector(:nth-of-type)")) {
// use it
}Specification
Sub-features
Support for each part of the feature (5). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| first-of-type | 1 | 12 | 3.5 | 3.1 | 18 | 4 | 2 |
| last-of-type | 1 | 12 | 3.5 | 3.1 | 18 | 4 | 2 |
| nth-last-of-type | 4 | 12 | 3.5 | 3.1 | 18 | 4 | 2 |
| nth-of-type | 1 | 12 | 3.5 | 3.1 | 18 | 4 | 2 |
| only-of-type | 1 | 12 | 3.5 | 3.1 | 18 | 4 | 2 |