-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter13.html
More file actions
126 lines (117 loc) Β· 2.71 KB
/
chapter13.html
File metadata and controls
126 lines (117 loc) Β· 2.71 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chapter 13: CSS Cascading</title>
<link rel="stylesheet" href="style.css">
<style>
/* For Rule 1 demo */
h1 {
color: green;
}
h1 {
color: blue;
}
/* For Rule 2 demo */
/* Universal */
* {
font-family: Arial, sans-serif;
}
h2 {
color: orange;
}
body h2 {
color: yellow;
}
.heading {
color: green;
}
body .heading {
color: blue;
}
.heading.first {
color: indigo;
}
#heading-one {
color: violet;
}
/* For Rule 3 demo */
#inline-demo {
color: green;
}
/* For Rule 4 demo */
#important-demo {
color: green !important;
}
/* For Inheritance demo */
.parent {
color: red;
}
.line {
color: green;
}
.first-line {
color: inherit;
}
</style>
</head>
<body>
<h2 class="chapter-header">Chapter 13: CSS Cascading</h2>
<!-- Rule 1 -->
<div class="tag-section">
<h3>Rule 1: The Last Declaration Wins</h3>
<div class="tag-demo">
<div class="head-demo">
<h1>My First Heading (should be blue)</h1>
<p>My first paragraph.</p>
</div>
</div>
</div>
<!-- Rule 2 -->
<div class="tag-section">
<h3>Rule 2: The More Specific Selector Wins</h3>
<div class="tag-demo">
<div class="head-demo">
<h2 id="heading-one" class="heading first">My First Heading</h2>
<p>First paragraph.</p>
<h2 id="heading-two" class="heading">My Second Heading</h2>
<p>Second paragraph.</p>
</div>
</div>
</div>
<!-- Rule 3 -->
<div class="tag-section">
<h3>Rule 3: Inline Style Overrides Internal/External</h3>
<div class="tag-demo">
<div class="head-demo">
<h2 id="inline-demo" style="color: red">This heading is red (inline wins)</h2>
</div>
</div>
</div>
<!-- Rule 4 -->
<div class="tag-section">
<h3>Rule 4: !important Is the Strongest</h3>
<div class="tag-demo">
<div class="head-demo">
<h2 id="important-demo" style="color: red">
This heading is green (!important wins over inline)
</h2>
</div>
</div>
</div>
<!-- Inheritance -->
<div class="tag-section">
<h3>Inheritance</h3>
<div class="tag-demo">
<div class="head-demo">
<article class="parent">
<h3>Parent Heading</h3>
<p class="line first-line">First line (inherits red from parent).</p>
<p class="line second-line">Second line (overridden to green).</p>
</article>
</div>
</div>
</div>
</body>
</html>