<! DOCTYPE html>
<meta charset= "Utf-8"/>
Inheritance of <title> styles </title>
<style>
Body {
font-size:30px;
}
p{
color:red;
}
</style>
<body>
<!--
Inheritance of styles:
Like a son can inherit a father's inheritance, in CSS, the style of the ancestor element can also be inherited by his descendant elements,
With inheritance, you can set some basic styles to ancestor elements, so that all descendant elements will automatically inherit those styles.
However, not all styles will be inherited by the quilt element, such as: background-related styles are not related to the style of the inheritance border related style, etc.
(We'll find out when we look at the reference manual.) But the default color of the background color is: transform transparent, so he is not inherited)
-
<div>
<p style= "Background:yellow;" >
I am a P tag in the text
<span> I am the text in span </span>
</p>
</div>
<span> I'm a span</span> outside the P element.
</body>
Inheritance of styles: