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

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.



More Tutorials:   SQL   PHP   HTML


Copyright 2007-2009   1keydata.com   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 Background-attachment
  CSS Background-color
  CSS Background-image
  CSS Background-position
  CSS Background-repeat
CSS Color
CSS Font
CSS Link
CSS List
CSS Table
CSS Position
  CSS Absolute
  CSS Relative
  CSS Fixed
  CSS Static
  CSS Top
  CSS Bottom
  CSS Left
  CSS Right
  CSS Overflow
  CSS Z-Index
CSS Text
CSS Float
CSS Clear
CSS Cursor
CSS Wrap

CSS Codes

Resources

CSS Tutorial German