1.四大标签选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div1 span {
color: greenyellow;
}
#div1>span {
color: red;
}
#s1+span {
color: yellow;
}
#s1~span {
color: skyblue;
}
</style>
</head>
<body>
<div id="div1" style="border: 1px aquamarine solid; border;">
div1<span>
字符<span>span.span</span>
</span>
<br />
div1<span id="s1">字符2</span>
div1<span>sapn字符3</span><span>sapn字符4</span>
</div>
<div id="div2" style="border: 1px aquamarine solid; border;">
div2<span>字符</span>
</div>
</body>
</html>
2.标签属性选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
div[id] {
width: 200px;
height: 100px;
background: red;
}
div[class] {
width: 100px;
height: 100px;
background: green;
}
div[style] {
background: #ff55ff;
}
</style>
</head>
<body>
<div id="div1">
div1
</div>
<div id="div2" class="divgroup" style="width: 400px;">
div2<span ></span>
</div>
<div id="div3">
div3
</div>
<div id="div4" class="divgroup" >
div4
</div>
<div id="div 5">
div5
</div>
<div id="div-6">
div6
</div>
</body>
</html>