Skip to main content

What is inheritance in CSS?

Inheritance in CSS is a mechanism whereby certain properties are automatically passed from a parent element to its children. For example, font-size, color, or line-height are inherited, while margin, padding, or border are not. Inheritance simplifies code because it lets you set shared styles at the top level instead of repeating them for every descendant.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.