About why the a tag in css cannot inherit the color of the parent class tag

Some styles of subclass semantic tags cannot inherit parent class tags

About why the a tag in css cannot inherit the color of the parent class tag

The span tag inherits the color but the a tag does not 

In the final analysis, there is a concept of cascading in CSS , that is, if an element is matched by multiple selectors at the same time, its cascading rules are:

<a style=""> inline style  

 <style> internal style 

 <link>quote style  

Browser user-defined styles 

browser default style

I will first check whether the program has directly set the style for the a tag . If it does not directly set the style for the a tag, then I will first check to see if the browser has set the style for the a tag . If not, I will finally look for inheritance style ;

Obviously, there is no style rule set for a in the code, and then check whether the browser has a default style. Here, the browser will set a default style for the a tag. At this time, the default style of the browser will be used, and there is no need to look for it again. Inherited styles too.

So why does the span tag inherit the style of the parent element? Because the browser does not set a default style for the span tag .

Inherited styles have the lowest priority! !

Only when the browser does not have any default styles, it will look for inherited styles.

Guess you like

Origin blog.csdn.net/hi1234560/article/details/127356435