Odd child: tr:nth-child(odd) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
Even child: tr:nth-child(even) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
Every third child: tr:nth-child(3n+1) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
6 | six |
7 | seven |
8 | eight |
9 | nine |
10 | ten |
First child: tr:first-child { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
Last child: tr:last-child { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
First 3 children: tr:nth-child(-n+3) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
Last 3 children: tr:nth-last-child(-n+3) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
Nth child/last in group: tr:nth-child(3n-1) { background-color:wheat; }
1 | one |
2 | two |
3 | three |
4 | four |
5 | five |
6 | six |
7 | seven |
8 | eight |
9 | nine |
10 | ten |
This paragraph must be red.
And this must not.
This must be black.
This paragraph must be blue.
And this must be red.
This paragraph must be blue.
And this must be red.
This paragraph must be purple.
And this must be purple too!
This paragraph must be green.
And this must be green too!