Xerobit
Frontend & Design

px vs rem: Which Unit to Use for Font Size, Spacing and Breakpoints

px vs rem decided with Chrome 157 measurements: rem font sizes follow the browser default size, px do not. Includes zoom results, em compounding and a decision table.

MA Mian Ali Khalid 7 min read
Free tool
Pixel to REM Converter
Convert px to rem, em, and percent, and vice versa. Configurable root font size. Bulk conversion mode for entire stylesheets.
Open tool →
On this page ⌄
  1. What the three units mean
  2. Is 1rem always 16px?
  3. px to rem at the default 16px base
  4. Test 1: px, rem, em and a nested em chain (default settings)
  5. Test 2: page zoom at 100%, 150% and 200%
  6. Test 3: the browser's default font size setting
  7. Test 4: media queries in px, em and rem
  8. Decision table
  9. FAQ
  10. Tested
  11. Sources

Use rem for font sizes, and for spacing that should grow with the text. Use px for hairlines, borders and shadows. The reason is one measurable difference: a rem value is multiplied by the browser's default font size, so it follows a user who raised that setting, while a px value stays fixed. In Chrome, page zoom scales both identically, so zoom is not the reason to choose rem.

This guide shows the measurements behind that rule, taken in real Chrome, and ends with a decision table. To convert values, the px to rem converter takes a root size and does the division for you.

What the three units mean

  • px: a CSS pixel, defined as 1/96 of an inch (CSS Values and Units Level 4, section 6.2). It does not depend on any font.
  • em: the computed font-size of the element it is used on. Used inside font-size itself, it means the parent's font size (MDN, CSS length).
  • rem: the font-size of the root element, normally <html>. MDN notes that 16px is "a common browser default" and that user preferences may change it.

Is 1rem always 16px?

No. 1rem is 16px only when the browser's default font size is 16px and nothing sets font-size on <html> in a way that changes it. Two things change it: a CSS rule such as html { font-size: 62.5% } (1rem becomes 10px), or the user's own font size setting in the browser. On the second point, the measurements below show 1rem at 24px in Chrome with the default set to 24px.

So 1.5rem is 24px by default, 15px under html { font-size: 62.5% }, and 36px for a user whose default is 24px.

px to rem at the default 16px base

pxrem
120.75
140.875
161
181.125
201.25
241.5
322
483

Each value is px divided by 16 (computed with Node and Python's fractions module).

Test 1: px, rem, em and a nested em chain (default settings)

Each element below was declared in Chrome 157 with the default font size at 16px and no rule on html. Values are the computed font-size or the measured width.

DeclarationComputed result
font-size: 24px24px
font-size: 1.5rem24px
font-size: 1.5em (parent 16px)24px
width: 15rem240px
width: 15em on an element whose font size is 24px360px
Three nested elements, each font-size: 1.5em24px, 36px, 54px
html { font-size: 62.5% }, then font-size: 1.5rem15px (root 10px)
html { font-size: 62.5% }, then width: 10rem100px

The nested chain is the main trap with em: each level multiplies the one above (16 x 1.5 = 24, 24 x 1.5 = 36, 36 x 1.5 = 54). rem always reads the root, so three nested elements declared 1.5rem would each be 24px.

Test 2: page zoom at 100%, 150% and 200%

Chrome was started with its default page zoom preference set to each level (the Preferences file value partition.default_zoom_level, which is a log base 1.2 of the zoom factor). The page then reported devicePixelRatio, innerWidth and the size of a 24px element and a 1.5rem element.

ZoomdevicePixelRatioinnerWidth (CSS px)24px element1.5rem element
100%1124824px24px
150%1.583224px24px
200%262424px24px

Both units gave identical results at every zoom level. Zoom changes how many device pixels one CSS pixel covers and shrinks the viewport in CSS pixels; it does not change computed px or rem values. WCAG 2.2 Success Criterion 1.4.4 (Resize Text) asks that text can be resized "without assistive technology up to 200 percent without loss of content or functionality", and W3C's Understanding document says scaling of content "is primarily a user agent responsibility" and lists whole-page zoom among the mechanisms (Understanding SC 1.4.4). Measured here, px text scales with page zoom exactly as rem text does. What px text cannot do is follow the browser's font size setting, which is the next test.

Test 3: the browser's default font size setting

Chrome's font size setting was changed by writing webkit.webprefs.default_font_size into a fresh profile's Preferences file (16 for the control, 24 for the test) and launching Chrome on that profile. The computed root font size confirmed the setting took effect. The last two columns use a font-size: 1.5rem element and a width: 10rem element.

Rule on htmlRoot font size at default 16Root font size at default 241.5rem text at 2410rem width at 24
none16px24px36px240px
font-size: 100%16px24px36px240px
font-size: 16px16px16px24px160px
font-size: 62.5%10px15px22.5px150px

Three results follow:

  1. With nothing on html, or with 100%, rem tracks the user's setting exactly (1.5 x 24 = 36px).
  2. html { font-size: 16px } pins the root. The user's 24px preference is discarded and rem behaves like px. If you want a rem base, use a percentage, not a px value.
  3. html { font-size: 62.5% } still scales with the setting (10px at 16, 15px at 24), but it makes 1rem a non-default size, so every rem value in the stylesheet needs converting by hand.

A font-size: 24px declaration measured 24px in every row. This is the practical accessibility case for rem: some users raise the default size instead of zooming, and font sizes written in relative units such as rem, em or a percentage of the default respond, while px sizes do not.

Test 4: media queries in px, em and rem

A page with min-width queries of 768px, 48em and 48rem was loaded with the viewport width searched by bisection (300 to 1600 px) for the first width at which each query matched.

Browser default font sizemin-width: 768pxmin-width: 48emmin-width: 48rem
16px768768768
24px76811521152

The em and rem queries flipped at 1152px (48 x 24) when the default was 24px. In every case the result was the same with html { font-size: 62.5% } and with html { font-size: 16px } present: in a media query, em and rem ignore the page's own rules and use the browser default. This matches the CSS Values and Units text that relative lengths outside an element, such as in media queries, use the initial value of the font properties. So html { font-size: 62.5% } does not make 48rem mean 480px in a query, which is a common surprise.

Choosing between them is a design decision: a px breakpoint stays at 768px whatever the user prefers, while an em or rem breakpoint moves the layout change to a wider screen for a user with larger text, which gives the larger text room before columns collapse.

Decision table

Use casePreferReason
Body and heading font sizeremFollows the browser default font size (Test 3); px does not.
Padding and margin around textremKeeps the gap in proportion when the text size changes.
Spacing inside a component that scales with its own textemTracks the component's font size; avoid deep nesting (Test 1).
Borders, hairlines, outlinespxA 1px line should stay 1px; scaling it adds nothing.
Box shadows, small radiipxDecorative detail does not need to follow text size.
Media query breakpointsem or remMoves with the user's default size (Test 4); px if you want fixed screen widths.
Icons next to textemScales with the surrounding text size.
Container and column widthsrem for text measure, % or ch for the restA readable line length is tied to text size; fluid layout widths are not.
Raster images and fixed assetspxRaster images have intrinsic pixel dimensions.

For rem to px values at other root sizes, the px to rem converter has a rem to px table and a custom root size field.

FAQ

What is the difference between em, rem and px units of measurement?

px is a fixed CSS pixel. em is relative to the font size of the element it is used on (or the parent's font size inside font-size). rem is relative to the root element's font size. em compounds through nesting, rem does not (Test 1).

Is 1rem always 16px?

No. It equals the root element's font size: 16px with Chrome's default setting and no rule on html, 10px with html { font-size: 62.5% }, and 24px when the browser default is 24px (Test 3).

What is 1.5 rem in font size?

1.5rem is 1.5 times the root font size: 24px at the default 16px base, 15px under html { font-size: 62.5% }, and 36px when the user's default font size is 24px.

Why use rem over pixels?

Because rem follows the browser's default font size setting and px does not. Zoom scales both the same way in Chrome (Test 2), so the benefit is for people who raise the default size rather than zoom.

Should I use px or rem for font size?

rem, with nothing on html or font-size: 100%, as the Chrome results in Test 3 show. Avoid html { font-size: 16px } because it overrides the user's setting.

Do rem units help accessibility?

They help for the font size setting, and they do not harm zoom. WCAG 2.2 SC 1.4.4 requires text to resize up to 200% without loss of content or functionality, which also depends on layouts that do not clip or overlap when text grows.

Tested

  • Chrome 157.0.8103.78 on Windows 11, headless, driven with Playwright (playwright-core 1.65.1) and Node 25.8, on 2026-11-17.
  • Font size setting: webkit.webprefs.default_font_size set to 16 and 24 in the profile's Preferences file. Page zoom: partition.default_zoom_level set to 0, 2.224 and 3.801, confirmed by devicePixelRatio of 1, 1.5 and 2.
  • Not tested: Firefox, Safari, mobile browsers, the in-browser text-only zoom option, and operating-system text scaling on phones.
  • The px to rem table was computed in Node and Python.

Sources

Related tools

Written by Mian Ali Khalid. More guides in Frontend & Design.