SyntaxStudy
Sign Up
CSS Inheritance vs Specificity
CSS Beginner 3 min read

Inheritance vs Specificity

Inheritance

Inherited values have no specificity — any declared value on the element wins over an inherited one, even specificity 0-0-0.

Example
body { color: navy; }    /* inherited by p */
p    { }                 /* inherits navy */
/* Declared styles always beat inherited styles */
p { color: green; }      /* 0-0-1 beats inherited navy */
/* explicit inherit keyword */
p { color: inherit; }    /* forces inheritance */
Pro Tip

Confused why a style is not applying? Check if it is inherited vs directly declared.