标签选择器、类选择器、id选择器
html代码
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<link rel="stylesheet" href="css/style.css">
<body>
<p>标签选择器</p>
<h1 class="class">类选择器</h1>
<h1 id="Heathcliff">id选择器</h1>
</body>
</html>
css代码
style.css
/*ID选择器*/
p{
color:deepskyblue;
}
/*类选择器*/
.class{
color:yellowgreen;
}
/*id选择器*/
#Heathcliff{
color: red;
}
测试访问
选择器的优先级
id > class > 标签
html代码
index02.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<link rel="stylesheet" href="css/style02.css">
<body>
<h1>RAINBOWSIX</h1>
<h1 class="ash">RAINBOWSIX</h1>
<h1 class="ash" id="zofia">RAINBOWSIX</h1>
</body>
</html>
css代码
style02.css
h1{
color:yellow;
}
.ash{
color:deepskyblue;
}
#zofia{
color: darkred;
}
测试访问