1. Use a four-digit string to represent the weight. Each number represents a level, with levels decreasing from left to right, with no carry between levels.
The contribution value of each selector is added to the final weight value.
2. The weight of inherited style is 0. Inline styles have greater weight than all selectors.
! The important command indicates priority.
When the weights are the same, cascading is used.
Example
#box ul li a.cur {color:red;} #box li .cur {color:green;} #box ul li a.cur The weight is 100+1+1+1+10 = 113 #box li .cur The weight is 100+1+10 = 111
The above are the calculation rules for CSS weight. I hope it will be helpful to everyone.