权重比较(id class 标签)

权重的取值:

按照 id   class  标签 的顺序在其位置上标出1或者0

例如下面的例子

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*权重:数数 id class 标签*/
        /*100*/
        #box{
         width:200px;
         height:200px;
         background-color: red;
        }
        /*010*/
        .box{
            width:200px;
            height:200px;
            background-color: green;
        }
        /*001*/
        div{
            width:200px;
            height: 200px;
            background-color: blue;
        }
    </style>
</head>
<body>
<div id="box" class="box"></div>

</body>
</html>
/*最终的颜色为red*/
原文地址:https://www.cnblogs.com/mmyy-blog/p/9504368.html