This pseudo-class matches elements based on their positions in the list of parent elements of child elements. The pseudo-class takes an argument N, which can be a keyword, number or numeric expression of the form a + b. For more information, see Understanding: nth-child pseudo-class expressions.
If N is a numeric or numeric expression: nth-child (N) matches elements preceded by N-1 siblings in the document tree.
The following example selectors are equivalent and will correspond to lines of strings with odd numbers:
tr:nth-child(2n+1) { โฎ declarations } tr:nth-child(odd) { โฎ declarations }
This sample selector will match the first three rows of any table:
tr:nth-child(-n+3) { โฎ declarations }
This sample selector will match any paragraph that is the first child of its parent:
p:nth-child(1) { โฎ declarations }
This, of course, is equivalent to the p:first-child. selector p:first-child.