Why doesn’t my child element inherit color from its parent when parent has more specific selector?

See: w3c: 6 Assigning property values, Cascading, and Inheritance – 6.2 Inheritance An inherited value takes effect for an element only if no other style declaration has been applied directly to the element. This style applies to an element with id=”my_id”: #my_id { color: red; } … and will apply (inherit) to an element nested … Read more

Can I override inline !important?

Let me begin by saying that generally inline styles can be overridden: .override {color:red !important;} <p style=”color:blue;”>I will be blue</p> <p style=”color:blue;” class=”override”>But I will be red</p> This behavior is described in W3 specs, where it is stated that !important declarations do not alter the specificity, but rather take precedence over “normal” declarations. That being … Read more

CSS Specificity and Inheritance

The .container rule doesn’t match the p element. So specificity is irrelevant here. Inheritance and specificity are separate concepts and the only time they interact is when more specific/less specific rules contain declarations with inherit. That is not the case here. As far as the p element is concerned, only the * rule applies, and … Read more

Relationship between !important and CSS specificity

Specificity in CSS only concerns selectors, not their associated declarations. !important applies to a declaration, so it alone plays no role in specificity. However, !important influences the cascade, which is the overall calculation of styles for a certain element when more than one of the same property declaration applies to it. Or, as Christopher Altman … Read more