CSS Inheritance


CSS Tutorial  >  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.

Next: CSS Class and CSS ID





Copyright 1keydata.com 2007, 2008, All Rights Reserved.   Privacy Policy



CSS Tutorial
CSS Syntax
Apply CSS
CSS Media Types
CSS Cascade
CSS Inheritance
CSS Class ID
CSS Div Span
CSS Length Units

CSS Box Model
CSS Margin
CSS Border
CSS Padding
CSS Background
CSS Color
CSS Font
CSS Link
CSS List
CSS Table
CSS Position
CSS Text
CSS Float
CSS Clear
CSS Cursor

CSS Codes

Resources