Given the following code:
<div id="bla">
<p class="blubber">Johnny Bananas</p>
</div>
and the style in head of that html doc:
<style>
div#bla{background:yellow}
p.blubber{background:purple}
</style>
Why is it that the child will be coloured purple and overlay its parent?
The
backgroundproperty is not inherited by children by default. Therefore, the background style ofdiv#bladoes not apply top.blubber, andp.blubbercan specify its own background color independently of its parent and regardless of specificity.And since
backgroundisn’t being inherited, no overriding actually takes place.