Inheritance
Some properties, such as color, font-family and line-height, are inherited: children use the parent value unless told otherwise. Others, such as border, margin and background, are not inherited.
The keywords inherit, initial and unset give you control. inherit copies the parent value, initial restores the default, and unset acts like inherit or initial depending on the property.
Example
<style>
.parent { color: darkgreen; border: 2px solid darkgreen; padding: 8px; }
.reset { color: initial; }
.force { border: inherit; }
</style>
<div class="parent">
Parent text
<p>Child inherits colour but not border.</p>
<p class="reset">Colour reset to default.</p>
<p class="force">Border forced to inherit.</p>
</div>Exercise
Make the span take its parent colour.
span { color: ; }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.