SyntaxStudy
Sign Up
HTML CSS Property Inheritance
HTML Intermediate 4 min read

CSS Property Inheritance

CSS Inheritance

Some CSS properties (color, font-family, line-height) are inherited by child elements. Others (margin, padding, border) are not.

Use inherit to force inheritance and initial to reset to browser default.

Example
body {
  font-family: Arial, sans-serif; /* inherited by all children */
  color: #333;
}

.box {
  border: 1px solid currentColor; /* currentColor uses inherited color */
  margin: inherit; /* force inherit margin from parent */
}
Pro Tip

Set font and color on body and let inheritance propagate — avoid repeating them in every selector.