From the course: CSS Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Inheritance and the cascade

Inheritance and the cascade - CSS Tutorial

From the course: CSS Essential Training

Inheritance and the cascade

- [Instructor] In CSS, styles can be inherited from ancestor elements to the descendant elements, which means styles can be applied to multiple elements with just one line of code. For instance, all page content is contained inside the body tag so it's common to define shared styles using body as the selector for all the descendant elements to inherit. This is more efficient than applying the style directly to each element. Inheritable styles are mainly related to typography, like font, family, or color. Non-inheritable styles are usually related to positioning elements or sizing, like width or height. But how do you know exactly which properties are inheritable or not inheritable? Well, you can check the CSS documentation. To find information about a specific property, I usually just do a web search with the keywords. For example, if I'm searching for the color property, I'll add that to my search plus the language, in…

Contents