Guides/ CSS & Layout
straighten

PX to REM Conversion Guide: When to Use Each CSS Unit

Pixels are concrete, rems are relative, ems are contextual — each has a right use case. This guide explains the conversion math, the accessibility reason rem exists, the full conversion table from 1 to 96 pixels, and exactly when each unit is the right tool.

April 2026 · 8 min read

The Conversion Formula

One formula covers 99% of cases:

rem = px / 16
px  = rem * 16

The 16 is the browser's default root font size. Every browser ships with html { font-size: 16px } by default, and 1rem equals that root size. So 16px = 1rem, 24px = 1.5rem, 8px = 0.5rem, and so on.

Full Conversion Table

PixelsREMCommon Usage
1px0.0625remHairline borders (usually keep as px)
2px0.125remBorders, outlines
4px0.25remTight spacing, micro gaps
6px0.375remSmall padding
8px0.5remStandard small spacing unit
10px0.625remLabels, captions
12px0.75remSmall text, badges
14px0.875remSecondary body text
16px1remDefault body text (the baseline)
18px1.125remEnlarged body / lead paragraphs
20px1.25remSubheadings
24px1.5remH3, generous padding
28px1.75remH2 small
32px2remH2, large section gaps
40px2.5remH1 mobile
48px3remH1 small desktop
56px3.5remHero headline
64px4remLarge hero / display
80px5remOversized display
96px6remHuge display text

Why REM Exists: Accessibility

The whole reason to prefer rem over px for typography: users can change their browser's default font size. In Chrome, go to Settings → Appearance → Font size and set it to "Large" or "Very Large." That multiplies the root font size from 16px to 20px, 24px, or even 32px.

If your site uses rem-based typography, everything scales proportionally — the user reading with vision impairment sees a genuinely larger interface. If your site uses pixel-based typography, their setting does nothing, and you've built something they can't comfortably read.

This is an accessibility requirement under WCAG 1.4.4 (Resize Text) — text must be resizable to 200% without loss of content or functionality. REM makes this trivial; pixel-only CSS usually violates it.

REM vs EM: The Critical Difference

Both are relative, but to different references:

  • REM is relative to the root element (<html>). 1rem is always the same size across your page.
  • EM is relative to the current element's font size. 1em inside a 24px heading equals 24px; inside a 12px caption it equals 12px.

This matters because EMs compound. If you nest font-size: 1.2em inside font-size: 1.2em inside font-size: 1.2em, the innermost text is 1.728× the size, not 1.2× — the kind of bug that breaks nested menus and nested lists.

When to Use Each Unit

Use CaseRecommended UnitWhy
Font sizes (typography)remAccessibility — respects user's zoom preference
Padding and marginremScales proportionally with text size
Component-internal spacingemScales with the component's own font size
Borders (1–2px)pxPixel-perfect — rem rounding can make them disappear
Box shadowspxScaling shadows looks weird; fixed feels right
Media query breakpointsem or pxem respects user zoom in media queries
SVG stroke widthspxSVGs aren't affected by root font scaling
Line heightsunitless (e.g. 1.5)Inherits cleanly across nested elements

The 62.5% Trick (and Why It's Controversial)

You'll sometimes see this at the top of a stylesheet:

html {
  font-size: 62.5%;
}

This makes 1rem = 10px instead of 16px, simplifying math: 1.4rem = 14px, 2.4rem = 24px. Popular in the 2010s.

Don't do this today. It breaks user-zoom expectations — when a user sets their browser to "Large" (20px), your baseline becomes 12.5px instead of 20px. The whole accessibility benefit of rem disappears. Stick with the default 16px root and embrace the decimals (or use a Sass function to auto-convert).

Modern Alternative: clamp() for Fluid Typography

Modern CSS can go beyond static rem values with clamp(min, preferred, max) for typography that scales smoothly across viewport sizes:

h1 {
  /* min 2rem, scales with viewport, caps at 4rem */
  font-size: clamp(2rem, 5vw, 4rem);
}

p {
  /* body text from 1rem to 1.125rem based on viewport */
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}

This removes the need for most media queries for typography. Pair with rem values inside the clamp() call to preserve accessibility.

Frequently Asked Questions

Is it OK to use px at all?
Yes — for things that shouldn't scale with text: borders (especially 1px hairlines), box-shadow offsets, and SVG stroke widths. The accessibility rule is specifically about readable content, not visual decoration.
What's the difference between rem and % for font-size?
On the root <html> element, they're identical: 100% = 1rem = 16px. Elsewhere, % is relative to the parent's font-size (like em), while rem is relative to the root. Use rem unless you specifically want inheritance.
Do I need to convert every px in my CSS?
No. Typography, padding, and margin should be rem. Borders, shadows, and component details can stay as px. Don't refactor aggressively — a partial migration (typography first) captures 90% of the accessibility benefit.
What about viewport units like vw and vh?
Useful for full-screen layouts (hero sections, full-viewport images) but dangerous for typography alone — they don't respect user zoom. Use inside clamp() with rem values to get scaling that still respects accessibility.
Can I use rem in media queries?
Use em in media queries, not rem — this is a known quirk. When a user zooms, em-based media queries update (meaning your breakpoints shift), while rem-based ones in some older browsers may not. @media (min-width: 48em) is the accessibility-friendly pattern for a 768px breakpoint.