Inheritance and specificity

Inheritance

CSS styles can be inherited from the ancestor to descendant elements.

applying the styles to parent elements will be inherited to all desendants.

Properties that can not be inherited.

https://www.w3.org/TR/CSS2/propidx.html

Specificity

Specificity determines how browsers decide which css rule takes precedence.

Precedence from lower to higher.

  1. universal (*)
  2. type (p)
  3. class (.example)
  4. id (#example)

Specificity Calculator

Previous
Next