How Inheritance Works

Another key concept is inheritance. Inheritance is the method by which a child element inherits the property values of its parent element, if those property values aren't declared in the child element.

NOTE

A child element is an HTML element that is nested within another element, while a parent element is an element within which another element is nested. In CSS, the term ancestor element is also sometimes used and refers to any element from which an element inherits properties (which could be the parent, grandparent, great grandparent, and so on, of that element).

To see how inheritance works in action, add the following styles to the style sheet for the Northwest Travel Ideas page (see Figure 5.5):

 <style type="text/css"> ...

Get Cascading Style Sheets (CSS) by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.