1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<html>
<head>
<style type="text/css">
/* Table odd / even test */
tr:nth-child(odd) { color: green; }
tr:nth-child(even) { color: purple; }
/* Check for negative n use */
tr:nth-child(-n+2) { font-weight: bold; }
/* Alternate paragraph colours in CSS */
p:nth-child(2n+1) { color: navy; } /* odd paragraphs */
p:nth-child(2n) { color: red; } /* even paragraphs */
/* Check nth-of-type and specificity */
span { font-weight: bold; }
span:nth-of-type(1) { font-weight: normal; }
span:nth-of-type(2n) { font-style: italic; }
</style>
</head>
<body>
<div>
<table>
<tr>
<td>This is the first cell in the first row of this table, and should be green, and bold</td>
<td>This is the second cell in the first row of this table, and should be green and bold</td>
</tr>
<tr>
<td>This is the first cell in the second row of this table, and should be purple and bold</td>
<td>This is the second cell in the second row of this table, and should be purple and bold</td>
</tr>
<tr>
<td>This is the first cell in the third row of this table, and should be green</td>
<td>This is the second cell in the third row of this table, and should be green</td>
</tr>
<tr>
<td>This is the first cell in the fourth row of this table, and should be purple</td>
<td>This is the second cell in the fourth row of this table, and should be purple</td>
</tr>
</table>
</div>
<div>
<p>
This should be navy, as this is the first paragraph in this page.
</p>
<p>
This should be red, as this is the second paragraph in this page.
</p>
<p>
This should be navy, as this is the third paragraph in this page.
</p>
<p>
This should be red, as this is the fourth paragraph in this page.
</p>
</div>
<div>
<p><span><i>This whole paragraph should be italic.</i></span> <span>But only this sentence should be bold.</span></p>
</div>
</body>
</html>
|