【控制的越精细,优先级越高,可以用firebug查看!】
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css优先级</title>
<style type="text/css">
p{
color: red;
}
.test2{
color: yellow;
}
#test1{
color: blue;
}
div #test1{
color: orange;
}
</style>
</head>
<body>
<div>
<!-- 既有id 又有class的p标签 -->
<p id="test1" class="test2">控制的越精细,优先级越高,可以用firebug查看</p>
</div>
</body>
</html>
效果: