Sunday, October 31, 2010

CSS Inheritance

In an HTML document, the tags have parent-child relationships. For example, <title> tag is always inside the <head> tag, so the <head> tag is the parent of the <title> tag. Inheritance means that the child node will inherit the styles defined for the parent node, unless that style (property) is explicitly defined for the child node.
For example, if the stylesheet is declared as follows:
p { color: #00FF00; }
strong { font-size:16px; }

the following HTML code,
<p>This is an example <strong>showing HTML inheritance.</strong></p>

renders
This is an example showing HTML inheritance.
The font color for the entire sentence is green, even though no color property was defined for the <strong> tag. This is because <strong> is a child element of <p>, so the <strong> inherits the style defined for <p>, which is this case is the font color.

Dont Miss Another Post Connect With Us !

Enter your email address:

0 comments: