First, Inheritance (inherited): Attributes that are set on the parent element are also available to descendant elements.
Application scenario: Generally used to set some common information on the Web page, text size, font color, etc.
Note the point:
1. Not all attributes can be inherited, only attributes that begin with color/font-/text-/Line can inherit.
2, the particularity of inheritance:
The text color and underline in a tag cannot be modified by inheritance (not biological)
The size of the text in the H tag cannot be modified by inheritance (not biological)
Second, cascading: CSS to deal with a conflict of ability
Note the point:
Cascading only occurs when the same label is selected in multiple selectors, and then the same property is set.
CSS: Cascading Style Sheets
Third, priority: When multiple selectors select the same label and set properties for the same tag, how the Cascade is determined by the priority level.
Three ways to prioritize your decisions:
-whether it is directly selected: Indirect selection is the way of inheritance, if it is indirectly selected, who is closer to the target tag to listen to WHO.
-whether it is the same selector: if it is the same selector, who writes in the back will listen to whom.
-whether different selectors: cascade according to the priority of the selector
Priority level:
ID > Classes > tags > wildcards (also direct selectors) > inherit > Browser default
Priority level! Important: Used to elevate priority permissions, only for direct selectors, not for indirect selectors.
Format:
ID selector {color:red;}
Tag Selector {color:green!important;}/promotion priority, at which time the label takes precedence over the ID
Weight of precedence: When multiple selectors are blended together to set properties, the weights can be used to calculate which selector has the highest precedence.
Weight Calculation rule:
1. When setting the property, the ID selector has the highest priority
2, the same number of ID selectors, the class name selector is the highest priority
3, the class name selector is as long as the tag Selector is the highest priority
4, the ID selector as many, the class name selector as many, tag selector as long, weight stop calculation, written in the last selector priority.
I'm a programmer.
Links: Https://www.jianshu.com/p/a22c194e6ca6
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.
The three main features of CSS based CSS are "important"