i'm working on a website where the client wants some titles at 0.875em.
I checked online, and the base em unit should be 16px for modern browsers. Well, if I set the text-size to 1em in chrome developper, it's set at 12px instead of 16px.
Tried setting body{font-size:100%}
at the beginning. No luck.
How do I put it back at 16px base?
Thanks!
That is because Chrome's default font-size is 12px. You should set the body and/or html element's font-size to 16px, like so:
html, body {
font-size: 16px;
}
This is assuming that there's no parent elements that change this font-size though, as em is a relative size to the nearest parent that sets a size. Check into rem if you want an absolutely sized font, however this isn't supported in older browsers so you'll need to provide a fallback.
To address what you describe as client request, set font-size: 0.875em
on those titles. It’s odd to want to use reduced font size for headings, but maybe there’s an explanation.
This has nothing to do with your idea of 1em as equalling 16px. The em
unit, when used for font-size
, stands for the font size of the parent element. Nothing more, nothing less.
You might need to ask the client what they really want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With