HTML & CSS
/Beginner
Inheritance
Definition
The mechanism by which certain CSS properties are passed down from a parent element to its children.
Explain Like I'm New
If you set the `color` and `font-family` on the `<body>` tag, you don't have to rewrite it for every single paragraph inside the body. The paragraphs 'inherit' the font and color from their parent.
Real World Example
Setting `font-family: 'Open Sans', sans-serif;` on the `html` selector so your entire website uses the same font automatically.
Common Use Cases
- •Writing DRY (Don't Repeat Yourself) CSS
- •Setting global themes
Interactive Example
Interview Questions
basic
- Do ALL CSS properties inherit automatically?
intermediate
- How do you force a property to inherit if it doesn't normally do so?