MeltingDog MeltingDog - 1 year ago 96
CSS Question

What's the correct way to set a base REM value in CSS?

Sorry, I'm a little unsure of this.

I want my base to be 16px. But all the resources I read about rem use percentages, eg:

html { font-size: 62.5%; }
body { font-size: 1.4rem; } /* =14px */
h1 { font-size: 2.4rem; } /* =24px */

If I want all my rem sizes to be relative to 16px, do I just make
html { font-size: 16px; }

Why use percentages?

Answer Source

yes it's right. You need to make your html font-size to 16px as your base font-size and then use rem with the rest. Rem sizes the element relative only to html while em sizes relatively to its nearest parent.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download