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?
*applies thefont-size: 18px;directly to the child<p>element. A style directly applied to a child element will take precedent over their inherited styles. If you wanted the.containerchildren 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...p{font-size: inherit;}This overrides the style applied by*!importantattributes around like crazy, which is a generally sloppy practice.