Child Pseudo Class

suggest change

The :nth-child(An+B) pseudo-class matches an element that has An+B−1 siblings before it in the document tree, for some non-negative integer n. Among a group of siblings, it counts elements of any type, not only elements of the same type.

A check mark means the child in that position matches. :nth-last-child(3) is the third sibling from the end, which is position 8 when there are 10 siblings.

Pseudo-class 1 2 3 4 5 6 7 8 9 10
:first-child yes
:nth-child(3) yes
:nth-child(n+3) yes yes yes yes yes yes yes yes
:nth-child(3n) yes yes yes
:nth-child(3n+1) yes yes yes yes
:nth-child(-n+3) yes yes yes
:nth-child(odd) yes yes yes yes yes
:nth-child(even) yes yes yes yes yes
:last-child yes
:nth-last-child(3) yes

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents