selector list argument of :nth-child and :nth-last-child CSS pseudo-classesExternal Link

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.

IE
Edge
Firefox
Chrome
Safari
Safari iOS
Opera Mini
Chrome Android
Android Browser
Samsung Internet
Globals: 95.42% of all users can use this feature, 95.42% fully supported, 0% partially supported
✓Supported
✗Not supported
Partial support