I've taken to using rem
's to size fonts in recent projects, then using px as a fallback for older versions of IE.
I've also been setting a font-size
of 62.5% on thehtml
so I can more easily set font sizes later on in the stylesheet, I then set a font-size of 1.4rem
on the body so unstyled elements have a base font-size
of at least 14 pixels, see the code below:
html { font-size: 62.5%; } /* font-size: 62.5% now means that 1.0 rem = 10px */
body { background: #fff; font-family: arial; font-size: 1.4rem; line-height: 1.6rem; }
The problem is, Chrome seems to handle this in a strange way ... Chrome seems to set the font sizes correctly on the inital page load, but on subsequent refreshes the font sizes are way bigger than they should be.
SEE FIDDLE (HTML copied below for future reference)
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>Page Title</title>
</head>
<body>
<p>This is a test, this font should have font-size of 14px.</p>
<p>This is a test, this font should have font-size of 14px.</p>
<p>This is a test, this font should have font-size of 14px.</p>
</body>
</html>
Remember, you might need to hit run once or twice in Chrome to see said effect.
Does anybody know what is causing this or if there's a way around it? Am I committing a crime by setting a 62.5% font-size
on the html
element (I realise there are arguements against doing so)?
font-size
on thehtml
element (I realise there are arguements against doing so)?" No, you're not. It should be 62.5% of the user-set default font size, which as you know is typically 62.5% of 16px = 10px. – Letterpressfont-size
&line-height
set on the body during subsequent refreshes, although I don't know why ... setting thefont-size
on the p itself (using 1.4rem) gets the desired results, but I don't want to have to set thefont-size
+line-height
in this way for everything. – Plainspokenp
elements, then uncheck and check thefont-size: 62.5%
it fixes itself. – Letterpressfont-size: 1.714rem;
easier to maintain, even if it means marginally less font sizes are defined in your stylesheet. – Plainspoken