Skip to content

/compare/css/em-vs-rem

CSS em vs rem: which unit to use

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
CSS
compares
em vs rem

rem is relative to the font size of the root element (html), usually 16px, so 1.5rem is the same size anywhere on the page. em is relative to the font size of the element itself (or, for font-size, of its parent), so values multiply when elements are nested. Use rem for most sizes, and em for spacing that should scale with the text of one component.

Criterion by criterion

Criterionemrem
Relative tothe element's font size (for font-size: the parent's)the root (html) font size
Nestingcompounds: 1.2em inside 1.2em is 1.44 times the outer sizenever compounds
Follows the user's browser font settingyes, through inheritanceyes, directly
Predictabilitydepends on where the element sitssame value everywhere
Good forpadding and icons inside a button that should grow with its textfont sizes, layout spacing, media queries

The compounding effect

html
<style>
  .em  li { font-size: 1.2em; }   /* nested lists keep growing: 1.2, 1.44, 1.728 … */
  .rem li { font-size: 1.2rem; }  /* every level is 1.2 × 16px = 19.2px */
</style>
<ul class="em"><li>one<ul><li>two<ul><li>three</li></ul></li></ul></li></ul>
<ul class="rem"><li>one<ul><li>two<ul><li>three</li></ul></li></ul></li></ul>

A sensible default

css
html { font-size: 100%; }              /* respect the user's setting, usually 16px */
h1 { font-size: 2.25rem; }
.card { padding: 1.5rem; }
.button { font-size: 1rem; padding: 0.5em 1em; }   /* padding scales with this button's text */

Sources