Interview Question

What is inheritance in CSS?

Inherited properties receive the parent’s computed value unless another declaration wins.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

Inheritance passes the computed value of some properties from a parent to its children. • Text properties such as color commonly inherit. • Box properties such as margin normally do not inherit. • The inherit, initial, unset, revert, and revert-layer keywords provide explicit control.

💡 Simple Example

body { color: #222; } a { color: inherit; }

⚡ Quick Revision

Inherited properties receive the parent’s computed value unless another declaration wins.