1,为什么要有选择器
2,元素选择器
对于大类的选择方便;
3,class选择器
注意:写style标签中一定要有.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.imb{color:blue}
</style>
<style>
.ing{background-color: aliceblue;}
</style>
</head>
<body>
<div>121344555</div>
<div class="imb">2222222</div>
<div class="imb ing">33333333</div>
</body>
</html>
效果图
所谓就近原则:在style标签中,若属性有冲突,则位置越靠近body标签的属性优先。
4,id选择器
什么是id选择器
5,通配符
6,群组选择器
div p{color:red;}
7,伪类选择器
8, 选择器的权重