CSS3 and the nth child
Numeric values
ol.nth-num li:nth-child(1), ol.nth-num li:nth-child(5) {
background-color: #cccccc;
}
- item 1
- item 2
- item 3
- item 4
- item 5
- item 6
Alternating elements
ol.nth-alt li:nth-child(odd) {
background-color: #cccccc;
}
ol.nth-alt li:nth-child(even) {
background-color: #eeeeee;
}
- item 1
- item 2
- item 3
- item 4
- item 5
- item 6
Formula based values
ol.nth-for1 li:nth-child(3n+0) {
background-color: #cccccc;
}
- item 1
- item 2
- item 3
- item 4
- item 5
- item 6
ol.nth-for2 li:nth-child(3n+5) {
background-color: #cccccc;
}
- item 1
- item 2
- item 3
- item 4
- item 5
- item 6
- item 7
- item 8
- item 9
- item 10
- item 11
- item 12