DEV Community

Discussion on: html{font-size:?} Responsive Magic

Collapse
 
tomekbuszewski profile image
Tomek Buszewski

Hello Batuhan.

I'm afraid this is a bad practice. While in most cases it works just fine, some users prefer to have a bigger default font size and are setting it in the browser. After such change, 62% will not be 10px, and your calculated values will change.

I am always hardcoding the html section:

html { 
  font-size: 8px;
}

That way I know that my layout is safe from user configs.

Collapse
 
b4two profile image
Batuhan

But as i give rem to most of the constitutive elements, website will be scaling in harmony and as far as i know giving a percentage to html also help the user who prefer their own font sizes. Does it really effect that bad?

Collapse
 
tomekbuszewski profile image
Tomek Buszewski

Yes, everything will scale just fine. But, when user turns up the font size, from, let's say 16, to 22, elements will be too big and the design will look awkward, elements may collide etc. Using fixed size in html and tuning certain elements to be responsive to user preferences is far safer, at least in my opinion.