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.
On this page ⌄
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-sizeof the element it is used on. Used insidefont-sizeitself, it means the parent's font size (MDN, CSS length). - rem: the
font-sizeof 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
| px | rem |
|---|---|
| 12 | 0.75 |
| 14 | 0.875 |
| 16 | 1 |
| 18 | 1.125 |
| 20 | 1.25 |
| 24 | 1.5 |
| 32 | 2 |
| 48 | 3 |
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.
| Declaration | Computed result |
|---|---|
font-size: 24px | 24px |
font-size: 1.5rem | 24px |
font-size: 1.5em (parent 16px) | 24px |
width: 15rem | 240px |
width: 15em on an element whose font size is 24px | 360px |
Three nested elements, each font-size: 1.5em | 24px, 36px, 54px |
html { font-size: 62.5% }, then font-size: 1.5rem | 15px (root 10px) |
html { font-size: 62.5% }, then width: 10rem | 100px |
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.
| Zoom | devicePixelRatio | innerWidth (CSS px) | 24px element | 1.5rem element |
|---|---|---|---|---|
| 100% | 1 | 1248 | 24px | 24px |
| 150% | 1.5 | 832 | 24px | 24px |
| 200% | 2 | 624 | 24px | 24px |
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 html | Root font size at default 16 | Root font size at default 24 | 1.5rem text at 24 | 10rem width at 24 |
|---|---|---|---|---|
| none | 16px | 24px | 36px | 240px |
font-size: 100% | 16px | 24px | 36px | 240px |
font-size: 16px | 16px | 16px | 24px | 160px |
font-size: 62.5% | 10px | 15px | 22.5px | 150px |
Three results follow:
- With nothing on
html, or with100%, rem tracks the user's setting exactly (1.5 x 24 = 36px). 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.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 size | min-width: 768px | min-width: 48em | min-width: 48rem |
|---|---|---|---|
| 16px | 768 | 768 | 768 |
| 24px | 768 | 1152 | 1152 |
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 case | Prefer | Reason |
|---|---|---|
| Body and heading font size | rem | Follows the browser default font size (Test 3); px does not. |
| Padding and margin around text | rem | Keeps the gap in proportion when the text size changes. |
| Spacing inside a component that scales with its own text | em | Tracks the component's font size; avoid deep nesting (Test 1). |
| Borders, hairlines, outlines | px | A 1px line should stay 1px; scaling it adds nothing. |
| Box shadows, small radii | px | Decorative detail does not need to follow text size. |
| Media query breakpoints | em or rem | Moves with the user's default size (Test 4); px if you want fixed screen widths. |
| Icons next to text | em | Scales with the surrounding text size. |
| Container and column widths | rem for text measure, % or ch for the rest | A readable line length is tied to text size; fluid layout widths are not. |
| Raster images and fixed assets | px | Raster 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_sizeset to 16 and 24 in the profile's Preferences file. Page zoom:partition.default_zoom_levelset to 0, 2.224 and 3.801, confirmed bydevicePixelRatioof 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
- W3C, Understanding Success Criterion 1.4.4: Resize Text (WCAG 2.2).
- MDN Web Docs, CSS length: em, rem and px definitions.
- W3C, CSS Values and Units Module Level 4: px as 1/96 inch, rem and em definitions, font-relative lengths in media queries.
Related tools
Pixel to REM Converter
Convert px to rem, em, and percent, and vice versa. Configurable root font size. Bulk conversion mode for entire stylesheets.
WebP to JPG Converter
Convert WebP to JPG, PNG or WebP in your browser. Batch files, set quality, pick a background for transparency. Nothing is uploaded.
Image Compressor
Compress JPEG, PNG, and WebP images in your browser. Adjustable quality, batch mode. Files never leave your device.
Color Picker
Pick colors, convert hex/RGB/HSL/OKLCH, and check WCAG contrast.
Written by Mian Ali Khalid. More guides in Frontend & Design.