concept inheritance in category css

appears as: inheritce, The inheritce
CSS in Depth

This is an excerpt from Manning's book CSS in Depth.

There’s one last way that an element can receive styles—inheritance. The cascade is frequently conflated with the concept of inheritance. Although the two topics are related, you should understand each individually.

If an element has no cascaded value for a given property, it may inherit one from an ancestor element. It’s common to apply a font-family to the <body> element. All the ancestor elements within will then inherit this font; you don’t have to apply it explicitly to each element on the page. Figure 1.8 shows how inheritance flows down the DOM tree.

Sass and Compass in Action

This is an excerpt from Manning's book Sass and Compass in Action.

In this section, we’ll look at situations when inheritance is appropriate to use, as opposed to mixins. Then we’ll cover advanced ways to put inheritance to work, before examining how inheritance works in detail. Finally, we’ll look at some of the potential pitfalls of using inheritance, and how to avoid them.

Inheritance and mixins are, in some ways, very similar in what they do. It’s important to know when each of them is the right tool to use, so that’s what we’ll go over first.

2.6.1. When to use inheritance

In section 2.5.1, we said that mixins should be “presentational” and share style, whereas classes should be “semantic” and convey meaning. Since inheritance is a relationship between classes (and sometimes other sorts of selectors), that relationship should be on the level of semantics. When an element having one class (such as .seriousError) means that it should have another (such as .error), you should use inheritance.