Precedence of CSS
The so-called CSS precedence refers to the order in which CSS styles are parsed in the browser.
The particularity of the style sheet describes the relative weights of the different rules, and its basic rules are:
1 The weights of the inline style sheet are highest style= ""------------1000;
2 The number of ID attributes in the statistics selector. #id--------------100
3 Number of class attributes in the statistics selector: class-------------10
4 the number of HTML tag names in the statistics selector. P---------------1
By adding the number of strings to bits by these rules, the final weight is obtained, and then the comparison is based on the left-to-right order.
1. The style priority in the text is 1,0,0,0, so it is always higher than the external definition.
2, there is!important declaration of the rules above all.
3. If the!important declares a conflict, the priority is compared.
4, if the priority is the same, according to the order in the source code to decide, later on the home.
5. The style obtained by inheritance has no specificity calculation, it is below all other rules (such as the rules defined by global selectors *).
css/Priority level