Elements inherit some CSS properties from their ancestors. You can check whether a property is inherited in the formal definition section on MDN, e.g. width and color.
1
2
3
4
5
<divclass="grandparent"><divclass="parent"><divclass="child">I inherit the green color from my parent, and the italic style from my grandparent. I don't inherit the border.</div></div></div>
1
2
3
4
5
6
7
.grandparent{font-style:italic;border:2pxsolidblack;/* not inherited */}.parent{color:green;}
CSS provides five universal property values to control inheritance.
Comments powered by Disqus. If comments are not loaded, Disqus may be blocked by your Internet service provider.