Properties applied to a parent works to a child or children but some properties (like of border) applied to the parent doesn't work to the child. So inheritance works but not always work in CSS. Let's make it clear by the following example:
Inheritance worked: color applied to <body> reaches everywhere.
Inheritance failed: border applied to <body> doesn't go to its child, only applied to <body> itself.
body {
color: #c619b8; /*color applied*/
border: 8px #000 solid; /*border applied*/
height: auto;
width: 700px;
}
<body> <!-- css applied to parent-->
<div>
<h1> heading 1</h1>
<p>
This is a <strong>good</strong> paragraph.
</p>
</div>
</body>
Comments
Post a Comment