UnitSwapper

px to rem converter

rem is the CSS unit that scales with the user's font-size setting; pixels do not. Type either value and the other updates, with the base font size adjustable for projects that change the root size.

16 px = 1 rem · 24 px = 1.5 rem · 14 px = 0.875 rem (base 16 px)

rem = px ÷ base · px = rem × base · em works the same way but against the parent's font size, not the root's.

Common values

Pixels to rem at three base sizes
pxrem (base 16)rem (base 14)rem (base 18)
8 px0.5 rem0.571 rem0.444 rem
10 px0.625 rem0.714 rem0.556 rem
12 px0.75 rem0.857 rem0.667 rem
14 px0.875 rem1 rem0.778 rem
16 px1 rem1.143 rem0.889 rem
18 px1.125 rem1.286 rem1 rem
20 px1.25 rem1.429 rem1.111 rem
24 px1.5 rem1.714 rem1.333 rem
28 px1.75 rem2 rem1.556 rem
32 px2 rem2.286 rem1.778 rem
36 px2.25 rem2.571 rem2 rem
40 px2.5 rem2.857 rem2.222 rem
48 px3 rem3.429 rem2.667 rem
56 px3.5 rem4 rem3.111 rem
64 px4 rem4.571 rem3.556 rem
72 px4.5 rem5.143 rem4 rem
96 px6 rem6.857 rem5.333 rem

When to use which unit

Use rem for font sizes, spacing that should grow with the text, and media queries, so that a user who sets a larger default font gets a larger layout. Use em for things that should scale with their own element's text, such as padding inside a button. Use px for hairlines, borders and anything that must stay a fixed number of device pixels. For print, points and millimetres are converted on the paper sizes page; for physical screen size, the PPI calculator.

Frequently asked questions

1.5 rem at the default 16 px root size (24 ÷ 16). If the root font size is 14 px it is 1.714 rem.

16 px in every browser by default, because the root font size is 16 px unless the site or the user changes it. That user setting is the reason rem exists: text sized in rem follows it, text in px ignores it.

rem is relative to the root element’s font size, em to the parent’s. Nested elements sized in em compound (1.2 em inside 1.2 em is 1.44 times the base); rem does not.

It makes the arithmetic easier (1.6 rem = 16 px) and still respects user settings, but it changes the default size for anything not explicitly sized. Most teams now keep 16 px and use a converter or a preprocessor function instead.

px to rem converter (and rem to px) with adjustable base size | UnitSwapper