PX to REM

Convert px to rem and back against any root font size, with a live batch converter for whole blocks of CSS.

=


Reference at root 16px

pxrem
1px0.0625rem
2px0.125rem
4px0.25rem
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
32px2rem
40px2.5rem
48px3rem
64px4rem

Why rem beats px for accessibility

When you size text in px, you pin it to an absolute value that ignores the reader. Someone who has raised their default browser font size - because they find 16px hard to read - gets no benefit, because your 14px stays 14px. Size in rem instead and everything scales from the root font size the user actually chose, so your layout respects their setting. That single change is one of the cheapest accessibility wins in front-end work.

The conversion, and the 62.5% trick

The maths is just division: rem = px / root. At the usual 16px root, 24px is 1.5rem and 8px is 0.5rem. A popular shortcut is to set html { font-size: 62.5% }, which makes 1rem equal exactly 10px. Now the conversions are trivial - 18px is 1.8rem, 42px is 4.2rem - while your components still scale with the user preference. Set the root above to 10 and the table updates to match this approach.

When px is still the right call

rem is not always the answer. Hairline borders (1px), box-shadow offsets and blur radii, and the occasional pixel-perfect icon usually want px, because you do not want a 1px border ballooning to 1.5px when the user bumps their font size. The rule of thumb: rem for anything type-related or layout-related that should breathe with the reader, px for fine visual details that should not.

Building out a design system? The hex to RGB converter helps with colour tokens, the CSS minifier shrinks the final stylesheet, and the shade generator builds consistent tints and shades.

Frequently asked questions

How do you convert px to rem?
Divide the pixel value by the root font size. At the default root of 16px, 24px is 24 / 16 = 1.5rem. Change the root size and every conversion updates.
What is the 62.5% trick?
Setting the root font size to 62.5% makes 1rem equal 10px, so px-to-rem maths becomes trivial: 18px is 1.8rem, 24px is 2.4rem. It keeps rem accessibility while letting you think in tens.
Should I use rem or px for everything?
Use rem for anything that should scale with the user font size - font sizes, spacing, max-widths. Keep px for hairline borders, box-shadow offsets and the odd 1px detail where scaling would look wrong.
What is the difference between rem and em?
rem is always relative to the root (html) font size, so it is predictable. em is relative to the current element font size, which compounds when elements nest. This tool converts rem, the safer default for layout.
Does Tailwind use rem?
Yes. Tailwind spacing and font sizes are defined in rem against a 16px root, which is why its scale lines up with the reference table here: 1 unit is 0.25rem, or 4px.