← Go Home

Inheritance


In CSS, inheritance is the mechanism by which certain properties automatically pass down from a parent element to its child elements.


This behavior is a core part of the cascade and helps you write more efficient and maintainable stylesheets.


  1. Inherited properties:

  2. These properties automatically apply their parent's computed value to their children unless explicitly overridden. Most properties related to text and typography are inherited, as it is desirable for text inside a container to have the same font and color


    Examples: color, font-family, font-size, font-weight, line-height, and text-align


  3. Non-inherited properties:

  4. These properties do not pass down to child elements. Instead, if no value is specified for a non-inherited property, the element uses its initial, default value


    Examples: background-color, border, margin, padding, width, and height


limportant rule


The !important rule in CSS is a keyword that gives a style declaration the highest possible priority, overriding any conflicting declarations for that property, regardless of specificity. It is used to force a specific style to be applied when other rules would otherwise take precedence

Learn More →