1. Cascading is a mechanism for resolving conflicts between CSS declarations.
CSS conflicts: Multiple identical maturity declarations, which are used for the same element will create a conflict.
2. Cascading process "1" comparison priority
Each declaration has a priority, and when a declaration conflicts, it retains a high priority, and the elimination priority is low.
The priority of a statement is related to his source and importance.
The source is generally divided into three parts: browser default style, author style, user style
The order of precedence from highest to lowest is: User style, author style, browser default style.
Importance: If a property value is followed by a "! Importent ", it represents an important statement, otherwise it is a general declaration.
Column:
p{color:red;}/*普通声明*/p{color:red importent;}/*重要声明*/
"2" Comparative particularity (specificity)
When the declaration of conflict, the specificity of the high will be retained, the special low will be eliminated.
The particularity of the declaration depends on the size of the actual scope of the rule, the smaller the applicable scope of the rule, the higher the particularity, the more the particularity.
Note:
*{声明块}/*通配符选择器,他的应用范围是整个页面*/html{声明块}/*这两个选择器时范围最大的选择器*/
Common style peculiarities from high to low rank:
1. Inline style
2.id selector
3. Class Selector
4. Element selector
5. Wildcard Selector
When "3" is more special, the essence is the specific value (value) of the comparative Declaration.
We assume that:
The inline style generates a value of (is the inline style generation 1 otherwise 0): a
The number of ID selectors generates a value of: b
The number of classes and pseudo-class selectors generates a value of: C
The number of elements and pseudo-element selectors generates a value of: D
Each declaration of a and A, B and B,c and c,d with the value of D, if obtained a maximum of a value, the maximum value corresponding to the declaration of the higher the specificity, if there is no maximum value is compared to the value of B, the comparison method is the same, and so on ... the HTML element will use the maximum value corresponding to the declaration.
css--Cascade