1.CSS Selector priority:!important > Inline style > ID >class and property selector > tag Selector > Wildcard selector Note: [Junior engineer Level]
2. The reason why there is priority issues, in the final analysis, these selectors have the right to heavy, the greater the weight value, the higher the priority! As shown below:
!important infinity[Positive Infinity]
Inline selector 1000[weights]
ID selector 100[Weight]
class| Property | pseudo-class selector 10[weight]
tag | pseudo element selector 1[weight]
wildcard character 0[weight]
The above weights satisfy the computational relationship, in mathematics, positive infinity plus 1 and positive infinity is the same, but in the computer, positive infinity plus 1 is more than positive infinity, that is, in the computer infinite is endless!
Need to note: here the 1000 and 100 and other numerical weights are not decimal, are 256 binary, so 1 and 2 is not the difference between 1, but the difference 256! "High-up knowledge points"
CSS selector priority and weight issues "CSS core issues"