-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
186 lines (162 loc) · 6.84 KB
/
index.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS Selectors by Priscila Garcia-Mendoza</title>
<link href="css/pre.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<style>
div#id-div{
background-color: lightblue;
}
li.my-list{
background-color: pink;
}
div#new-div,li.new-list{
background-color: lavender;
}
ul.my-kids > li{
background-color: lightgreen;
}
div.grandkids li{
background-color: lightsalmon;
}
.add-border{
border: 1px solid #000
}
.add-background{
background-color: antiquewhite;
}
</style>
</head>
<body>
<header>
<h1 class="page-header">CSS Selectors by Priscila Garcia-Mendoza</h1>
<nav>
<ul>
<li><a href="#id">id</a></li>
<li><a href="#class">class</a></li>
<li><a href="#compound">compound</a></li>
<li><a href="#child">child</a></li>
<li><a href="#descendant">descendant</a></li>
<li><a href="#multiple">multiple</a></li>
</ul>
</nav>
</header>
<fieldset>
<legend><a id="id">id</a></legend>
<p>ids can be applied to only one item on a page</p>
<p>Here's how we hook an id attribute to an element:</p>
<pre><code>id="id-div"</code></pre>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>div#id-div{
background-color:lightblue;
}</code></pre>
<p>Here's what it looks like:</p>
<div id="id-div">Inside my-div
</div>
</fieldset>
<fieldset>
<legend><a id="class">class</a></legend>
<p>classes can be applied to several items to a page</p>
<p>Here's how we hook a class attribute to an element:</p>
<pre><code>class="my-list"</code></pre>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>li.my-list{
background-color:pink;
}</code></pre>
<p>Here's what it looks like:</p>
<div>
<ul>
<li class="my-list" >I'm inside an li with a class of my-list</li>
<li class="my-list">I'm inside an li with a class of my-list</li>
<li class="my-list">I'm inside an li with a class of my-list</li>
</ul>
</div>
</fieldset>
<fieldset>
<legend><a id="compound">compound</a></legend>
<p>Compounds selectors allow us to use more then one selector for a set of rules. The selectors must be separated by commas.</p>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>div#new-div,li,new-list{
background-color:lavender;
}</code></pre>
<p>Here's what it looks like:</p>
<div id="new-div"> Im inside a div with id new-div</div>
<div>
<ul>
<li class="new-list" >I'm inside an li with a class of new-list</li>
<li class="new-list">I'm inside an li with a class of new-list</li>
<li class="new-list">I'm inside an li with a class of new-list</li>
</ul>
</div>
</fieldset>
<fieldset>
<legend><a id="child">child</a></legend>
<p>The child selector allows us to access the elements that are immediately inside the current element.</p>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>ul.my-kids > li{
background-color: lightgreen;
}</code></pre>
<p>Here's what it looks like:</p>
<div>
<ul class=my-kids>
<li>I'm inside an li that is a child of a ul with a class of my-kids</li>
<li>I'm inside an li that is a child of a ul with a class of my-kids</li>
<li>I'm inside an li that is a child of a ul with a class of my-kids</li>
</ul>
</div>
</fieldset>
<fieldset>
<legend><a id="descendant">descendant</a></legend>
<p>The descendant selector selector allows us to hook to an element at any depth inside the current element.</p>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>div.grandkids li{
background-color: lightsalmon;
}</code></pre>
<p>Here's what it looks like:</p>
<div class="grandkids">
<ul>
<li>I'm inside an li that is a descendant of a div with a class of grandkids</li>
<li>I'm inside an li that is a descendant of a div with a class of grandkids</li>
<li>I'm inside an li that is a descendant of a div with a class of grandkids</li>
</ul>
</div>
</fieldset>
<fieldset>
<legend><a id="multiple">multiple classes</a></legend>
<p>we can apply multiple classes by placing them in the class attribute with a space between each.</p>
<p>Here's how we hook a multiple classes to an element:</p>
<pre><code>class="add-border add-background"</code></pre>
<p>Here's how the CSS is applied to the element:</p>
<pre><code>.add-background{
background-color: #antiquewhite;
}
.add-border{
border-color: #000;
}
</code></pre>
<p>Here's what it looks like:</p>
<div>
<ul>
<li class="add-border add-background">I'm inside an li with 2 classes</li>
<li class="add-border add-background">I'm inside an li with 2 classes</li>
<li class="add-border add-background">I'm inside an li with 2 classes</li>
</ul>
</div>
</fieldset>
<footer class="page-footer">
<p><small>© 2023 by
Priscila Garcia-Mendoza, All Rights Reserved ~
<a id="html-checker" href="#" target="_blank">Check HTML</a> ~
<a id="css-checker" href="#" target="_blank">Check CSS</a></small>
</p>
</footer>
<script>
document.getElementById("html-checker").setAttribute("href","https://validator.w3.org/nu/?doc=" + location.href);
document.getElementById("css-checker").setAttribute("href","https://jigsaw.w3.org/css-validator/validator?uri=" + location.href);
</script>
</body>
</html>