Skip to content
thecalculatorstudio

PX to REM Converter (and REM to PX)

Enter a size in pixels or rem and your root font size. You get the conversion, the em value for a parent size, the size in points and a table of common sizes.

Last reviewed

px
px
px

rem

1.5rem

at a root font size of 16px

In rem
1.5rem
In em (parent 16px)
1.5em
In points
18pt
As a percentage of the root
150%

1rem is the font size of the root element. Browsers usually default to 16px, but readers can change it, which is why rem scales with their settings and px does not.

The formula

rem = pixels ÷ root font size.

A rem is the font size of the root element, which is usually the <html> element. MDN notes that a common browser default is 16px, but that readers can change it in their settings. So with the usual default, 1rem is 16px, 1.5rem is 24px and 0.875rem is 14px.

Enter a number of pixels and a root font size and you get the rem value. Turn the switch round to go from rem to pixels, which is rem × root font size. The page also shows the em value for a parent font size you choose, the size in points and the figure as a percentage of the root.

Pixels to rem at a 16px root

Pixels rem
8 0.5
10 0.625
12 0.75
14 0.875
16 1
18 1.125
20 1.25
24 1.5
28 1.75
32 2
36 2.25
40 2.5
48 3
56 3.5
64 4

Worked examples

  • 24px at a 16px root: 24 ÷ 16 = 1.5rem.
  • 14px at a 16px root: 14 ÷ 16 = 0.875rem.
  • 2.25rem at a 16px root: 2.25 × 16 = 36px.
  • 18px with a 10px root: 18 ÷ 10 = 1.8rem. If the root is 10px, then 1rem is 10px.
  • 12px as em inside a 16px parent: 12 ÷ 16 = 0.75em, and it equals 9pt.

rem, em and pt

  • rem is relative to the root font size, so it is the same everywhere on the page.
  • em is relative to the font size of the element itself, and for the font-size property, to the inherited size of the parent. Nested elements with an em font size compound: 0.875em inside 0.875em is 0.765625 of the original size.
  • pt: MDN says 1in = 96px = 72pt, so 1px = 0.75pt and 1pt = 4/3 px. A 12pt font is 16px.

Why use rem

Pixel sizes do not change when a reader raises the browser’s default font size, while rem sizes do. Because the root size can be set by the reader, using rem for text and spacing lets a page respect their choice. Setting the root font size to a fixed pixel value on html overrides that choice, so many developers leave it alone and convert from the 16px default instead. Some use 62.5% on the root so that 1rem is 10px at the default, which makes the sums easier but depends on the default being 16px.

Common mistakes

  • Assuming 1rem is always 16px. It is the root font size, which readers can change.
  • Confusing em and rem. em depends on the element or its parent, and nested ems compound.
  • Dividing when you should multiply. Pixels to rem divides by the root size, and rem to pixels multiplies.
  • Using rem for everything. Borders and hairlines are often best left in pixels.

For other units, use the unit converter and the length converter. To check text colours, see the colour contrast checker.

The same rem for different readers

A line of text set at 1.5rem is 1.5 × 16 = 24px for a reader who keeps the default of 16px, and 1.5 × 20 = 30px for a reader who has chosen 20px. This is the purpose of using rem: the text grows with the reader’s choice, and the layout follows. Nested em sizes grow faster: three levels of 1.25em give 1.25 × 1.25 × 1.25 = 1.953125 times the starting size.

How it is calculated

Pixels and rem are held as exact decimals. rem is the pixel value divided by the root font size, em is the pixel value divided by the parent size, and points are pixels × 72 ÷ 96. Results are rounded half up to four decimals.

Frequently asked questions

How do I convert px to rem?

Divide the pixels by the root font size. At the common default of 16px, 24px is 24 ÷ 16 = 1.5rem and 14px is 0.875rem. To go back, multiply the rem value by the root font size.

How many pixels is 1rem?

It is the font size of the root element, usually the html element. MDN says a common browser default is 16px, but that user-defined preferences may change it, so 1rem is often but not always 16px.

What is the difference between rem and em?

rem is relative to the root font size and is the same everywhere. em is relative to the font size of the element itself, or for font-size to the inherited size, so nested em values compound.

How many points is a pixel?

MDN gives 1in = 96px = 72pt, so one pixel is 0.75pt and one point is 4/3 px. A 12pt font is 16px and a 16pt font is about 21.33px.

Why use rem instead of px?

rem sizes scale with the root font size, so they follow a reader’s browser settings, while px sizes stay fixed. This helps people who raise their default text size.

What root size should I enter?

16 unless your stylesheet changes the html font size. If you set html to 62.5%, the root is 10px at the default and you should enter 10.

Related calculators

Sources