-
Notifications
You must be signed in to change notification settings - Fork 1
/
children-and-descendants.html
89 lines (61 loc) · 2.04 KB
/
children-and-descendants.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<title>Match children and descendants</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- HTML5 (?) <meta charset="utf-8"> -->
<style type='text/css'>
.match-here .match-if-descendent { /* Rule 1*/
color : maroon;
background-color: greenyellow;
}
.match-here > .match-if-child { /* Rule 2 */
color : yellow;
background-color: red;
}
div {
border: 1px solid black;
margin: 5px;
background-color: #eee;
}
div > div {
background-color: #ccc;
}
div > div > div {
background-color: #aaa;
}
</style>
</head>
<body>
<div class='match-here'>
This is the <code>.match-here</code> div.
<div class='xyz'>
This div does not match, its class is <code>.xyz</code>
<div class='match-if-descendent'>
This is a <code>.match-if-descendent</code> div. It matches <i>Rule 1</i> because it's a (direct or indirect) descendent of <code>.match-here</code>
(the corresponding selector is <code>.match-here .match-if-descendent</code>)
</div>
<div class='match-if-child'>
This is a <code>.match-if-child</code> div. It doesn't match because it is not a (direct) child of <code>.match-here</code>
(the corresponding selector is <code>.match-here > .match-if-child</code>).
</div>
</div>
<div class='match-if-descendent'>
This div matches <i>Rule 1</i> because it's a (direct or indirect) descendent of <code>.match-here</code>.
</div>
<div class='match-if-child'>
This div matches <i>Rule 2</i> because it's a direct descendent of <code>.match-here</code>.
</div>
</div>
<p>
<div class='dont-match'>
This is the <code>.dont-match</code> div.
<div class='match-if-descendent'>
This div does not match the first or second rule.
</div>
<div class='match-if-child'>
Neither does this div.
</div>
</div>
</body>
</html>