The Limits of Inheritance

Inheritance isn't all-powerful. Many CSS properties don't pass down to descendent tags at all. For example, the border property (which lets you draw a box around an element) isn't inherited, and with good reason. If it were, then every tag inside an element with the border property would also have a border around it. For example, if you added a border to the <body> tag, then every bulleted list would also have a box around it, and each bulleted item in the list would also have a border (Figure 4-2).

Note

There's a complete list of CSS properties in Appendix A, CSS Property Reference, including details on which ones get inherited.

Here are examples of times when inheritance doesn't strictly apply:

Note

These types of conflicts between styles are very common, and the rules for how a browser deals with them are called the cascade. You'll learn about that in the next chapter.