Introduction
Inheritance
Some CSS properties are inherited: children automatically get the value from their parent. Others are not.
body {
font-family: Arial, sans-serif;
color: #333;
}Every paragraph, heading and list inside <body> now uses Arial and #333, without any extra rules.
| Usually inherited | Not inherited |
|---|---|
color, font-*, line-height, text-align, letter-spacing, visibility | margin, padding, border, background, width, height, display |
Controlling inheritance
a { color: inherit; } /* take the parent's colour */
p { margin: initial; } /* reset to the CSS default */