!important > id > class > tag
!important 属性顾虑器 权重高于内联样式;
.testClass{
color:red !important;
}
注:!important在IE6中是不被识别的。
ID选择器,权值为0100;
<head>
#name{
color:red;
}
</head>
<body>
<div id="name">Kelly</div>
</body>
class选择器,权值为0010;
<head>
.name{
color:red;
}
</head>
<body>
<div class="name">My name is Kelly</div>
</body>
tag选择器,权值为0001;
<head>
div{
color:red;
}
</head>
<body>
<div>Kelly</div>
</body>