CSSMar 14, 2026 · Updated Oct 13, 2026 · 4 min read

How to Convert PX to REM in CSS

The px-to-rem formula, plus what we measured in Chromium when a reader raises their default font size from 16px to 20px: px text stays put, rem scales, 62.5% still scales, a px root locks it, and media queries ignore your root size.

Woodtype, wood blocks, wood type — illustrating How to Convert PX to REM in CSS
📏
Try the PX to REM Converter
Free, no signup
→
DG
Derek Giordano
Designer & Developer
In this guide
01The Conversion Formula02What Happens When a Reader Changes Their Font Size03When to Use px, rem and em04Setting the Root Font Size

The Conversion Formula

rem = px ÷ root font size. With the browser's usual 16px default: 24px = 1.5rem, 14px = 0.875rem, 48px = 3rem. If your stylesheet sets a different root size, divide by that instead; the PX to REM Converter takes any base. Common values at a 16px base: 10px = 0.625rem, 12px = 0.75rem, 18px = 1.125rem, 20px = 1.25rem, 32px = 2rem, 64px = 4rem.

The 16px figure is a browser default, not a fixed rule. MDN's definition of rem puts it plainly: a common default is 16px, "but user-defined preferences may modify this". That is the whole reason to use rem.

What Happens When a Reader Changes Their Font Size

We set Chromium's default font size (the setting in Chrome under Appearance, Font size) to 16px and then 20px, applied with the DevTools protocol, and read the computed sizes on a test page (October 13, 2026; script in our test folder).

StylesheetUser default 16pxUser default 20px
font-size: 16px on text16px16px: ignores the setting
font-size: 1rem, no root size set16px20px
padding: 1.5rem24px30px
html { font-size: 62.5% }, then 1rem10px12.5px: still scales
html { font-size: 16px }, then 1rem16px16px: locked
@media (min-width: 40rem) at a 700px windowmatches (40rem = 640px)no match (40rem = 800px)

Three findings. Text sized in px does not follow the reader's font setting, while rem does. The often-criticized 62.5% trick does not break that scaling, because a percentage is a share of the user's own default; what breaks it is setting the root in pixels (html { font-size: 16px }), which some resets do. And media queries ignore your root font size: a rem or em in a media query is measured against the browser's initial font size, so with the 62.5% root, 40rem in a query is still 640px, not 400px. The Media Queries specification defines this.

Note the other route to larger text: browser zoom (Ctrl or Cmd and +) enlarges px and rem alike, so a px layout survives zoom. The font-size setting is the case px fails, and some readers rely on it instead of zoom. WCAG 2.2 success criterion 1.4.4 requires text to resize to 200% without loss of content or function; using rem for type and spacing makes both routes work.

When to Use px, rem and em

Setting the Root Font Size

The safest choice is to leave the root alone, or set it as a percentage:

html { font-size: 100%; }   /* = the reader's default */
body { font-size: 1rem; }

If you prefer the 62.5% shorthand so that 1.6rem means 16px, it still respects the reader's setting, but remember to set body { font-size: 1.6rem } or text falls to 10px, third-party components written for a 16px root will come out smaller, and media-query rem values will not match your 1rem = 10px arithmetic. Never set the root in px.

Frequently Asked Questions

How do I convert pixels to REM?+
Divide the pixel value by the root font size (default 16px). So 24px = 24/16 = 1.5rem. Use the PX to REM Converter for instant results with any base size.
Why should I use REM instead of PX?+
Because rem follows the reader's default font size. In our Chromium test a 20px default made 1rem text 20px while 16px text stayed 16px. Browser zoom enlarges both units, but the font-size setting only reaches rem and em.
What is the default root font size?+
16px in current browsers unless the reader changes it: Chrome, Firefox and Safari all let users pick a different default, and rem follows that choice. If you set html { font-size: 20px } you override the reader; a percentage such as 125% keeps their setting as the base.
Try it yourself

Use the PX to REM Converter — free, no signup required.

⚡ Open PX to REM Converter
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.