Wednesday, September 3, 2008

Property Inheritance

Inheritance is the system by which elements automatically obtain certain properties from their ancestor elements. For example if the declaration color: red; is applied to a div element, then that declaration will also apply to p elements that are within it.
Inherited properties have no specificity at all, not even zero. An inherited property is overridden by values applied to the property using the universal selector (*). This is because the universal selector has a specificity of zero.
Most of the properties that apply to the "box" of an element such as borders, margins, padding and backgrounds, are not inherited by descendants of that element.

No comments: