This is really a preference. Some will tell you to set body{font-size: 62.5%;} (this is 10px if the default browser is 16px) and then use em from now on. So, if you want a 22px font size, you would use 2.2em . However, most developers have their own opinions on this issue. Some always use interest. Some use pixels always.
em is a measurement relative to the current font size, for example:
body{font-size: 16px;} .someClass{font-size: 1em;} .someOtherClass{font-size: 2em;} .anotherClass{font-size: .5em;}
If no font-size set for any parent in the document, the default browser font size (most likely 16 pixels) == 1em .
The percentage works similarly to the fact that they relate to the parent container, in contrast to the font size of the parent container.
body{width: 800px;} .someClass{width: 100%;} .someOtherClass{width: 200%;} .anotherClass{width: 50%;}
The problem in both scenarios is that both cascades mean that if you have two classes with font-size: 2em and you font-size: 2em them, there will be 4em in the inner element.
source share