3 <style type=
"text/css">
4 /* Table odd / even test */
5 tr:nth-child
(odd
) { color: green
; }
6 tr:nth-child
(even
) { color: purple
; }
8 /* Check for negative n use */
9 tr:nth-child
(-n
+2) { font-weight: bold
; }
11 /* Alternate paragraph colours in CSS */
12 p:nth-child
(2n+1) { color: navy
; } /* odd paragraphs */
13 p:nth-child
(2n) { color: red
; } /* even paragraphs */
15 /* Check nth-of-type and specificity */
16 span
{ font-weight: bold
; }
17 span:nth-of-type
(1) { font-weight: normal
; }
18 span:nth-of-type
(2n) { font-style: italic
; }
26 <td>This is the first cell in the first row of this table, and should be green, and bold
</td>
27 <td>This is the second cell in the first row of this table, and should be green and bold
</td>
30 <td>This is the first cell in the second row of this table, and should be purple and bold
</td>
31 <td>This is the second cell in the second row of this table, and should be purple and bold
</td>
34 <td>This is the first cell in the third row of this table, and should be green
</td>
35 <td>This is the second cell in the third row of this table, and should be green
</td>
38 <td>This is the first cell in the fourth row of this table, and should be purple
</td>
39 <td>This is the second cell in the fourth row of this table, and should be purple
</td>
46 This should be navy, as this is the first paragraph in this page.
49 This should be red, as this is the second paragraph in this page.
52 This should be navy, as this is the third paragraph in this page.
55 This should be red, as this is the fourth paragraph in this page.
60 <p><span><i>This whole paragraph should be italic.
</i></span> <span>But only this sentence should be bold.
</span></p>