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 within having class="my_class" only if its color property is otherwise unspecified.

…which no longer is the case once you declare:

.my_class {
    color: blue;
}

Leave a Comment