TTKTheTextKit

PX to REM: Formula, Conversion Table and When to Use Each CSS Unit

Learn the px to rem formula, see a conversion table from 8px to 96px, and how rem differs from em, pt and vw. Checked against Chromium on 6,000 cases.

By TheTextKit TeamPublished

Px to rem table at a 16px root: 12px is 0.75rem, 16px is 1rem, 24px is 1.5rem, 32px is 2rem, 48px is 3rem

A table of five common pixel sizes and their values in rem when the root font size is 16 pixels. 12 pixels is 0.75 rem. 16 pixels is 1 rem. 24 pixels is 1.5 rem. 32 pixels is 2 rem. 48 pixels is 3 rem.

To convert px to rem, divide the pixel size by the root font size. Browsers set that to 16 pixels unless a page or a visitor changes it, so 16px is 1rem, 24px is 1.5rem and 8px is 0.5rem. The formula is one division, but three things make it less simple in practice. The root size can change. Rem and em behave differently inside nested elements. And some units, such as vw, can work against readers. This guide gives the formula, a conversion table, and a clear answer to which unit to use, and it shows how we checked our converter against a real browser.

How to convert px to rem

  1. Open the PX to REM Converter.
  2. Type the size and leave the unit on px.
  3. Set the root font size if your CSS changes it. Leave it at 16 otherwise.
  4. Copy the rem value, which is written with up to four decimals and no trailing zeros.

By hand, use rem = px ÷ root font size. For 24px at the default root, 24 ÷ 16 = 1.5, so the size is 1.5rem. To go back, multiply: 1.5rem × 16 = 24px. The root size is the font size of the <html> element. As MDN's page on CSS lengths puts it, a common browser default is 16px, but user-defined preferences may modify this.

PX to REM conversion table

This table is for a 16px root, calculated by the tool. A size that is a multiple of 4px gives a clean decimal.

PixelsRem at a 16px rootPixelsRem at a 16px root
8px0.5rem24px1.5rem
10px0.625rem32px2rem
12px0.75rem40px2.5rem
14px0.875rem48px3rem
16px1rem64px4rem
18px1.125rem80px5rem
20px1.25rem96px6rem
24px as rem at three root sizes: 1.5rem at 16px, 2.4rem at 10px, 1.2rem at 20px

A table of how 24 pixels converts to rem at three root font sizes. With a 16 pixel root it is 1.5 rem. With a 10 pixel root it is 2.4 rem. With a 20 pixel root it is 1.2 rem.

The same 24px is a different rem value for every root size.

The root size changes every row. Take 24px: at a 16px root it is 1.5rem, at 10px it is 2.4rem, and at 20px it is 1.2rem. That is why the converter has its own root size box, and why a pasted table from another site can be wrong for your project.

rem vs em

Both are relative units, but they are relative to different things. MDN describes rem as the font size of the root element and em as the calculated font size of the element, or of its parent when used on font-size itself. The difference shows up as soon as elements are nested.

We set three nested elements to font-size: 1.5em and another three to 1.5rem, with a 16px root, and read the sizes from Chromium:

Nesting levelSize with 1.5emSize with 1.5rem
Outer24px24px
Middle36px24px
Inner54px24px
Three nested elements at 1.5em are 24, 36 and 54 pixels, and at 1.5rem they are all 24 pixels

A table of three nested elements measured in Chromium at a 16 pixel root. With 1.5 em they are 24, 36 and 54 pixels. With 1.5 rem they are all 24 pixels.

Each em multiplies the one above it. A rem always counts from the root.

The em compounds: each level multiplies the one above it. A rem always counts from the root. That makes rem the safer choice for font sizes and spacing across a page, and em the right choice when something should scale with the text around it, such as the padding of a button.

The other units: pt, pc, vw and percent

The converter handles four more units, all defined by CSS:

  • pt. One point is 1/72 of an inch, and 1in is 96px, so 1pt is 4/3 of a pixel. 12pt is 16px, and 10pt is 13.3333px.
  • pc. One pica is 12pt, or 1/6 of an inch, which is 16px.
  • vw. One vw is 1 percent of the viewport width. At a 1280px viewport, 5vw is 64px.
  • percent. For font size, 150% is 1.5 times the parent font size, the same as 1.5em.
CSS units in pixels: 12pt is 16px, 1pc is 16px, 5vw is 64px at a 1280px viewport, 150 percent is 1.5 times the parent

A table of four CSS units and their size in pixels. 12 points is 16 pixels. 1 pica is 16 pixels. 5 vw is 64 pixels at a 1280 pixel viewport. 150 percent is 1.5 times the parent font size.

Each unit is defined from the pixel or from its context.

Be careful with vw for text. The W3C guidance for resizing text, WCAG 1.4.4, lists the incorrect use of viewport units to resize text as a failure. Text sized only in vw does not grow when a reader zooms. Combine it with a rem value, for example with clamp(), if you need fluid type.

The 62.5 percent root trick

Some stylesheets set html { font-size: 62.5%; }. At the browser default that makes the root 10px, so 1rem equals 10px and the arithmetic is easy: 24px is 2.4rem, and 14px is 1.4rem. The cost is that body text is now tiny, so you restore it, for example with body { font-size: 1.6rem; }.

Is it a problem for accessibility? Not by itself. 62.5 percent is a share of the visitor's own default, so if they raise their default text size, everything still scales. What can harm accessibility is a root size set in pixels, because that ignores their setting. WCAG also does not ban pixel values, since browser zoom enlarges them. The rule that matters is that text can be resized up to 200 percent without loss of content.

Converting a whole type scale

A designer hands you sizes in pixels, and you want rem. Divide each by 16 and name them once, as variables or in the rules themselves. A common scale comes out like this, with the arithmetic done by the tool:

RolePixelsRem
Small print14px0.875rem
Body text16px1rem
Heading 320px1.25rem
Heading 224px1.5rem
Heading 132px2rem
body { font-size: 1rem; }
small { font-size: 0.875rem; }
h3 { font-size: 1.25rem; }
h2 { font-size: 1.5rem; }
h1 { font-size: 2rem; }

Sizes that are not a multiple of 4px give longer decimals. 15px is 0.9375rem, and 11px is 0.6875rem. Keep all the digits the tool gives you, because rounding to 0.94rem makes the text a little smaller than the design asked for.

Mistakes to avoid

  • Assuming a 16px root. If a stylesheet changes the root size, every rem value changes with it, so enter the real root size in the converter.
  • Using em for font sizes in nested lists. Each level multiplies the one above, as the table showed. Use rem, and keep em for padding that should follow the text.
  • Setting the root in pixels. html { font-size: 16px; } ignores a visitor's own default. A percentage such as 100% follows it.
  • Sizing text only in vw. It breaks zoom, as WCAG notes. Mix in a rem value.
  • Rounding too early. Convert once, with all the decimals, at the end.

rem or px: which to use

UseGood choiceWhy
Font sizesremFollows the visitor's default text size
Spacing and layoutrem, or px for fine detailsScales with text, so layouts hold up when the size changes
Borders and thin linespxA 1px border should stay 1px
Padding that follows the textemScales with the element's own font size
Fluid headingsclamp() with remFluid without breaking zoom
Print stylesptA point is a print unit

How we tested it

We compared the converter with Chromium. A script made 6,000 random cases: a value, a unit from px, rem, em, pt, pc, vw and percent, a root font size and a parent font size. For each, Chromium computed the font size in pixels, and we compared that with the tool.

CheckResult
Values below Chromium's 10,000px font size cap5,969 of 5,969 matched
Cases above that cap31, which Chromium cuts to 10,000px
Converting a to b and back to a20,000 of 20,000 returned the start value
CSS unit converter checked against Chromium: 5,969 of 5,969 sizes matched, 31 above the cap, 20,000 of 20,000 round trips

A table of three checks of the CSS unit converter. All 5,969 sizes below Chromium's 10,000 pixel font size cap matched its computed values. 31 cases were above the cap. All 20,000 round trips from one unit to another and back returned the start value.

Every size inside the browser's limits matched.

Two limits apply. Chromium prints a computed size to six significant digits, so we compared with a matching tolerance. And a zero root, parent or viewport size has no meaningful answer, so the tool shows n/a instead of infinity.

Frequently asked questions

How do I convert px to rem?

Divide the pixel size by the root font size. With the browser default of 16px, 16px is 1rem, 24px is 1.5rem and 8px is 0.5rem. If your CSS sets the html element to a different size, divide by that size instead.

What is the difference between rem and em?

A rem is relative to the root font size, so it is the same everywhere. An em is relative to the font size of the parent element, so it compounds when elements are nested. Three nested 1.5em elements at a 16px root are 24, 36 and 54px, while three 1.5rem elements are all 24px.

How many px is 1pt?

One point is 4/3 of a pixel, about 1.3333px, because CSS defines an inch as 96px and a point as 1/72 of an inch. So 12pt is 16px and 10pt is about 13.3333px.

Should I set the root font size to 62.5 percent?

It is a convenience, not a requirement. It makes 1rem equal 10px at the browser default, so 24px is 2.4rem. Because it is a percentage of the user's own setting, text still follows their preference, but you must restore the body text size yourself.

Is my data uploaded?

No. The conversion runs in your browser, and the values you type are not sent anywhere or stored. The tool needs no account and keeps nothing after you close the page.

Convert px to rem now

Open the PX to REM Converter, set your root size, and copy the value for every unit at once. If you are choosing colors as well, the Color Converter checks contrast, and our guide to converting HEX to RGB explains the arithmetic. Everything runs in your browser, so nothing is uploaded.

Try these free tools

100% in your browser

Keep reading

All articles →