CSS entry notes nine: the three major characteristics of CSS

CSS has three major characteristics, namely cascading, inheritance, and priority. Let's understand one by one

1. Cascading : When the label style conflicts, the nearest principle will be adopted, that is, the following style will cover the previous style.
Such as:

	div {
    
    
	   color : red;
	   }
	div {
    
    
	color: pink;
	}
  <div>
     <p>我是什么颜色</p>
  </div>
  //此时文字会是粉红色   		

2. Inheritance : Child tags will inherit the style of the parent tag. Child tags usually inherit the styles of the parent's text, font, and line elements, but the inner and outer margins will not be inherited. If the row height is not set, it will automatically inherit the row height of the label’s nearest parent label

3. Priority :

Insert picture description here
Weight attention points :
1. It is composed of four groups of numbers and will not be carried.
2. When judging, compare from left to right
3. Inherited weight is 0

Weight overlap plus : often appear in compound selectors

Guess you like

Origin blog.csdn.net/m0_52021758/article/details/113061388