For example, if we need to set a div
's font-size
to 22px
, is there a possible way to let the descendants of this div
still inherit from the font-size
from body
? (or any inheritable style, thanks to @Sourabh for pointing out background
is not inherited).
I think a key point is that so that we can change the style of body
or some parent and let it pass through, even though there is an intermediate change of style. So preferably, we won't do it by:
body, #foo * { font-size: 16px }
#foo { font-size: 22px }
This is related to the case as described in How to solve flicker on iPad when event delegation is used? , where the -webkit-tap-highlight-color
need to be set for a div
, but the descendants of this div
will be best to inherit what is above this div
(the parent of this div
).
I can use JavaScript to put the style of this div
in a temporary variable, and then change the div
's style, and then change the style for just the immediately children of this div
to the value of that temporary variable, but then whatever that is set for the style of body
won't get inherited by those children or their descendants.