1

What is 62.5% here! And what does it do ** **

*,
*::before,
*::after {margin: 0;
    padding: 0;
    box-sizing: inherit;
}  

html {
    font-size: 62.5%;
    box-sizing: border-box;
}

Google.

Word Rearranger
  • 1,306
  • 1
  • 16
  • 25
asdfj
  • 23
  • 1
  • 6
  • 2
    What is your question? Are you asking what a `%` in a `font-size` declaration does or are you looking for some assistance centering (vertically & horizontally) a div? If it's the last one, please provide your HTML also. If it's the first one, read here: [CSS Font-Size: em vs. px vs. pt vs. percent](https://kyleschaeffer.com/css-font-size-em-vs-px-vs-pt-vs-percent) – EGC Oct 16 '19 at 20:36
  • your question is quite not clear.. you've applied 62.5% to a font. It has nothing to do with positioning a div horizontally or vertically. If you can, edit your question to what exactly you want to achieve – mamaye Oct 16 '19 at 20:39
  • I know about font sizing and percentages. But I'm curious about "font-size: 62.5%", I see this quite often in codes. Why set it to 62.5% not 70% or 80%. Thanks for help! – asdfj Oct 16 '19 at 20:46
  • Can you you then revise/edit your answer to be more clear. Thanks – TroySteven Oct 16 '19 at 20:57

2 Answers2

5

font-size: 62.5%; on html tag is a method helping you to convert easily px to rem.

As 62.5% of the default font size in browser (16px) is equal to 10px, convert pixel values to rem values become easy. For example, 1.6rem will have a 16px rendering (16/10=1.6). 

You can get more informations about CSS font size units on this link : https://medium.com/code-better/css-units-for-font-size-px-em-rem-79f7e592bb97

-2

Percent in font size is used to make it scalable wrt different devices. i.e mobile, desktop ipad etc.

user3115056
  • 1,266
  • 1
  • 10
  • 25