13. How does inheritance work in CSS?

Inheritance in CSS means that some properties are automatically passed down from a parent element to its child elements. Properties such as color, font-family, and line-height are inherited, while others like margin, padding, and border are not.

/* Example of inheritance */ .parent { color: blue; /* This property will be inherited by children */ font-size: 20px; /* This property will also be inherited */ } .child { font-weight: bold; /* This property will not be inherited */ }
devFlipCards 2024

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.