Given the following code:
* {
font-size: 18px;
}
.container {
font-size: 50%;
}
<div class="container">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate explicabo fugiat laborum minus ullam? Amet delectus facilis id quam temporibus.
</p>
</div>
The result is that the <p>
tag has 18px font-size applied.
But shouldn't every element that is inside of the div container inherit the font-size I apply to it?
Regardless of the *
selector applying the font-size to the <p>
tag,
because a tag is only worth 1 point and a class is worth 10 points?
` element. A style directly applied to a child element will take precedent over their inherited styles. If you wanted the `.container` children to be an exception, you could do `.container * { font-size: 50% }` or `.container p { font-size: 50%; }`, `.container { font-size: 50%; } .container p { font-size: inherit; }`, etc. Or even use an `!important`...
– Tyler Roper May 01 '17 at 14:55