1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN">
4 <title>:nth-last-child() pseudo-class
</title>
5 <style type=
"text/css">.green
{ background-color : lime
! important
}
6 ul
> li:nth-last-child
(odd
) { background-color : red
}
7 ol
> li:nth-last-child
(even
) { background-color : red
}
8 table
.t1
tr:nth-last-child
(-n
+4) { background-color : red
}
9 table
.t2
td:nth-last-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-29.html" title=
":nth-last-child() pseudo-class">
12 <link rel=
"next" href=
"css3-modsel-30.html" title=
":nth-of-type() 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>First list item
</li>
20 <li class=
"green">This second list item should have a green background
</li>
21 <li>Third list item
</li>
22 <li class=
"green">This fourth list item should have a green background
</li>
23 <li>Fifth list item
</li>
24 <li class=
"green">This sixth list item should have a green background
</li>
27 <li class=
"green">This first list item should have a green background
</li>
28 <li>Second list item
</li>
29 <li class=
"green">This third list item should have a green background
</li>
30 <li>Fourth list item
</li>
31 <li class=
"green">This fifth list item should have a green background
</li>
32 <li>Sixth list item
</li>
35 <table border=
"1" class=
"t1">
47 <td>Green row :
3.1</td>
52 <td>Green row :
4.1</td>
57 <td>Green row :
5.1</td>
62 <td>Green row :
6.1</td>
68 <table class=
"t2" border=
"1">
71 <td class=
"green">green cell
</td>
74 <td class=
"green">green cell
</td>
77 <td class=
"green">green cell
</td>
81 <td class=
"green">green cell
</td>
84 <td class=
"green">green cell
</td>
87 <td class=
"green">green cell
</td>
91 <td class=
"green">green cell
</td>
94 <td class=
"green">green cell
</td>
97 <td class=
"green">green cell
</td>