-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathcss-selectors.html
51 lines (42 loc) · 1.27 KB
/
css-selectors.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
<!DOCTYPE html>
<html>
<head>
<title>CSS Selectors</title>
<style>
/* To target all h1 tags */
h1 { color: orange; }
/* To target all paragraph tags */
p {
color: red;
font-size:130%;
}
/* id selectors allow you to style an HTML element that has an id attribute, regardless of their position in the document tree. */
#intro {
color: blue;
background-color: gray;
}
/* class selectors */
.info {
font-size:100px;
}
/* These selectors are used to select elements that are descendants of another element. When selecting levels, you can select as many levels deep as you need to.
For example, to target only <em> elements in the first paragraph of the "contact" section */
#contact .first em {
color: pink;
background-color:gray;
}
</style>
</head>
<body>
<h1>A Sample Heading</h1>
<p> This is a paragraph </p>
<div id="intro">
<p> This paragraph is in the intro section.</p>
</div>
<div class="info">
info section
</div>
<div id="contact">
<p class="first">This is a <em> paragraph.</em></p>
</body>
</html>