The weight problem of CSS pseudo-class selector!

for all kinds of posts seen on the Internet, the weights of pseudo-class selector and class selector are all 10, but this is not the case in actual measurement

    <style type="text/css">
        .container div{
            width: 100px;
            height: 100px;
        }

        .container:nth-child(1) div{
            background: blue;
        }

        .container div:nth-child(1){
            background: red;
        }
    </style>

    <body>
        <div class="container">
            <div></div>
        </div>
    </body>
The weight of the code above, . Container:nth-child (1) div and .container div:nth-child (1) should be the same. My judgment is that the order in which the two styles are exchanged, the color of the div will change. However, the above pseudo-class selector + tag, the weight should be 11, the other is the class selector + pseudo-class selector, the weight should be 20. What is it like, please?

the other set of tests is as follows:

    <style type="text/css">
        div{
            width: 100px;
            height: 100px;
        }

        div:nth-child(1){
            background: blue;
        }

        .demo{
            background: red;
        }
    </style>

    <body>
        <div class="demo"></div>
    </body>

here, changing the order of div:nth-child (1) and .demo , div is always blue, does it mean that the pseudo-class selector is more important than the class selector?

was confused by these two groups of tests. I hope God explains that the test browser is chrome 69

.
Css
Sep.16,2021
Things like

: hover: link are pseudo-class selector, which has the same weight as pseudo-class selector.
a:hover this is a composite selector, and the weight superimposed is larger than the class selector.


I think the weight of div:nth-child (1) should be 1 / 10
, while the weight of .demo is 10

.

.container:nth-child (1) the weight of div is 10 / 10
.Container div:nth-child (1) is 10 / 10


in the above set of tests, the weight of the two selectors is

< table > < tbody > < tr > < td > 0 < / td > < td > 0 < / td > < td > 2 < / td > < td > 1 < / td > < / tr > < tr > < td > 0 < / td > < td > 0 < / td > < td > 2 < / td > < td > 1 < / td > < / tr > < / tbody > < / table >

the weight of the following set of tests is

< table > < tbody > < tr > < td > 0 < / td > < td > 0 < / td > < td > 1 < / td > < td > 1 < / td > < / tr > < tr > < td > 0 < / td > < td > 0 < / td > < td > 1 < / td > < td > 0 < / td > < / tr > < / tbody > < / table >

for another example, the weights of 11 class selectors and 1 id selector are

, respectively. < table > < tbody > < tr > < td > 0 < / td > < td > 1 < / td > < td > 0 < / td > < td > 0 < / td > < / tr > < tr > < td > 0 < / td > < td > 0 < / td > < td > 11 < / td > < td > 0 < / td > < / tr > < / tbody > < / table >

most of the tutorials on the css weight network are wrong (id selector weight 100, class selector weight 10, as if 11 class selections are more important than one id selector). It is recommended to read
English

.

1 the weight of the id id selector is 100, and the weight of the class selector is 10 < class selector

2. The binary in the id selector is not decimal, but 256, so 10 class selectors are not equal to one class selector

.
Menu