-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSS specificity.html
43 lines (35 loc) · 1.02 KB
/
CSS specificity.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=z, initial-scale=1.0">
<title>Document</title>
<style>
/* The specificity of this selector is 1 */
h1 {
color: yellow;
}
/* This is an example of an attribute selector. The specificity of this selector is 10 */
[data-x=a]{
color: green; /* [Attribute selector] */
}
/* The specificity of this selector is 1 + 10 = 11*/
h1.cpurple {
color: purple;
}
/* The specificity of this selector is 10 */
.cred {
color: red;
}
/* The specificity of this selector is 1 + 10 + 10 + 10 + 10 = 41 */
a.harryclass.rohan-class[href]:hover {
color: blueviolet;
}
</style>
</head>
<body>
<div>
<h1 class="yellow cred cpurple" data-x="a">CSS Specificity</h1>
</div>
</body>
</html>