I do not quite understand what is happening:
Using the universal selector *
reset the parameters, including font-size: 0;
, then in the markup for the header block, set the font size, for example, 16px. There are several headers in this block, and as I understand it, they must inherit the font size of the parent ... but in fact it turns out to be 0.
Question: When using *
, in this case, each tag needs to set the font size, since the property will not be inherited from the parent, but taken according to the rule "for all tags" and for redefinition it is necessary to set the property explicitly to each element?
|
1 answer
For the selector * becomes more important than the standard value. To indicate that internal tags should follow the parent size, you need to exceed the asterisk priority. For example:
CSS
* {font-size: 10px;} .txt {font-size: 20px;} .txt * {font-size: inherit;}
HTML
текст вне <div class="txt"> текст 0 <span>текст 1</span> <strong>текст 2</strong> <div>текст 3</div> </div>
Displays internal content of 20px in size as indicated in the txt
class and everything will be inherited, and this example:
CSS
* {font-size: 10px;} .txt {font-size: 20px;}
HTML
текст вне <div class="txt"> текст 0 <span>текст 1</span> <strong>текст 2</strong> <div>текст 3</div> </div>
Displays all 10px text as specified in the selector *.
- font-size: 10; - can so font-size: 10px? - soledar10
- @ soledar10 works in any version. But yes, it was implied after all 10px. - Telion
- If you checked without a doctype, then yes, the browser will calculate in px, and if with a doctype, there will be an error invalid property value - soledar10
- @ soledar10 true, it was a sampler even without <html> - Telion
|
*
reset the font size, then for a block with some content, set the size, but the tags inside the block do not inherit this rule and have to set it explicitly to tags directly - pepel_xDfont-size: inherit
to inherit? You can do something likediv * {font-size: inherit;}
- Telion