1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN">
4 <title>:nth-child() pseudo-class
</title>
5 <style type=
"text/css">.green
{ background-color : lime
! important
}
6 ul
> li:nth-child
(odd
) { background-color : red
}
7 ol
> li:nth-child
(even
) { background-color : red
}
8 table
.t1
tr:nth-child
(-n
+4) { background-color : red
}
9 table
.t2
td:nth-child
(3n+1) { background-color : red
}</style>
10 <link rel=
"first" href=
"css3-modsel-1.html" title=
"Groups of selectors">
11 <link rel=
"prev" href=
"css3-modsel-28.html" title=
":nth-child() pseudo-class">
12 <link rel=
"next" href=
"css3-modsel-29.html" title=
":nth-last-child() pseudo-class">
13 <link rel=
"last" href=
"css3-modsel-d4.html" title=
"Dynamic updating of :first-child and :last-child">
14 <link rel=
"up" href=
"./index.html">
15 <link rel=
"top" href=
"../../index.html">
19 <li class=
"green">This first list item should have a green background
</li>
20 <li>Second list item
</li>
21 <li class=
"green">This third list item should have a green background
</li>
22 <li>Fourth list item
</li>
23 <li class=
"green">This fifth list item should have a green background
</li>
24 <li>Sixth list item
</li>
27 <li>First list item
</li>
28 <li class=
"green">This second list item should have a green background
</li>
29 <li>Third list item
</li>
30 <li class=
"green">This fourth list item should have a green background
</li>
31 <li>Fifth list item
</li>
32 <li class=
"green">This sixth list item should have a green background
</li>
35 <table border=
"1" class=
"t1">
37 <td>Green row :
1.1</td>
42 <td>Green row :
2.1</td>
47 <td>Green row :
3.1</td>
52 <td>Green row :
4.1</td>
68 <table class=
"t2" border=
"1">
70 <td class=
"green">green cell
</td>
73 <td class=
"green">green cell
</td>
76 <td class=
"green">green cell
</td>
80 <td class=
"green">green cell
</td>
83 <td class=
"green">green cell
</td>
86 <td class=
"green">green cell
</td>
90 <td class=
"green">green cell
</td>
93 <td class=
"green">green cell
</td>
96 <td class=
"green">green cell
</td>