12-1100.04%
2-1120.02%
4-1101.21%
3.1-80%
3.2-8.40.01%
4-210.01%
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since November 2025.
The newest versions of :nth-child() and :nth-last-child() accept an optional of S clause which filters the children to only those which match the selector list S. For example, :nth-child(1 of .foo) selects the first child among the children that have the foo class (ignoring any non-foo children which precede that child). Similar to :nth-of-type, but for arbitrary selectors instead of only type selectors.