Toolnido

PX to REM Converter: Pixels, rem and em for Your Base Size

Convert px to rem and em, or rem back to px, for any root size. Includes a px to rem conversion table for the default 16px base to copy into CSS.

px to rem conversion table (16px root)

rem values for common pixel sizes when the html font size is the browser default of 16px. Skip to the calculator

pxrem
8px0.5rem
10px0.625rem
12px0.75rem
13px0.8125rem
14px0.875rem
15px0.9375rem
16px1rem
18px1.125rem
pxrem
20px1.25rem
22px1.375rem
24px1.5rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
48px3rem

rem = px / 16. If your html font size is not 16px, set it in the converter below and its table follows.

Use the calculator for other values

Everything is worked out in this browser. Nothing is uploaded or sent to a server.

Convert a size

Browsers start at 16 px. Use the size set on the html element in your CSS.

Leave blank to use the root size. em is relative to the parent element, rem to the root.

Separate with commas or spaces, for example 15, 22, 30.

Embed this calculator

Paste this HTML into your page. It shows the calculator in a frame with a link back to this page. No ads, no cookies and no tracking scripts are added to your site.

When to use this

  • You have a design in pixels and want the rem values for your CSS.
  • Your root font size is not 16 px and you need the whole scale for it.
  • You want to turn rem or em back into pixels to check a size.

How to use

  1. Type the value and choose its unit: px, rem or em.
  2. Set the root font size. It is 16 px unless your CSS changes it.
  3. Add a parent font size only if you want em values for a nested element.
  4. Press Convert. Copy the CSS value or the table.

Examples

  • 24 px at the default size: 24 px divided by a root size of 16 px is 1.5 rem.
  • Common sizes at a 16 px root: 12 px = 0.75 rem, 14 px = 0.875 rem, 16 px = 1 rem, 18 px = 1.125 rem, 20 px = 1.25 rem, 24 px = 1.5 rem and 32 px = 2 rem. Each is the pixel size divided by 16.
  • A 10 px root size: Some projects set the root to 10 px so 1.6 rem is 16 px. Set the root size to 10 and the table shows the whole scale.

How it works

rem = px / root font size, and em = px / the font size of the parent element. Going the other way, px = rem x root size. The root size is 16 px unless you change it, because that is the default text size in current browsers when neither the user nor the page changes it. Values are rounded to 4 decimals for CSS.

Checked against:

  • W3C CSS Values and Units Level 4, font-relative lengths: em is equal to the computed font-size of the element; rem is equal to the computed em unit on the root element.

Understanding the result

1 rem is the root font size in pixels, so px divided by the root size is rem. 1 em is the font size of the parent element, so px divided by the parent size is em. If you leave the parent blank the tool uses the root size for em, which is only right when the parent has the root size. Values are shown with up to 4 decimals and no trailing zeros.

Assumptions this tool makes

  • The root size you type is the computed font size of the html element, in px.
  • For em, the parent size you type is the computed font size of the parent element, in px.

Limitations

  • This converts numbers. It does not read your stylesheet, so it cannot know the real parent size of an element.
  • If a visitor changes their browser font size, rem and em values scale with it, as long as your CSS does not fix the root size in px. px values never scale. The table shows the size you entered, not each user's setting.
  • em means different things in different places: for font-size it is the parent's size, for other properties such as line-height or padding it is the element's own size, and in media queries it is the browser's default size. This tool only models the font-size case.
  • Long decimals are rounded to 4 places, so a very small rem value can be off by a fraction of a pixel.

FAQ

How do I convert px to rem?

Divide the pixels by the root font size. At the default 16 px, 24 px is 24 / 16 = 1.5 rem.

What is 14px, 16px, 18px or 20px in rem?

With the usual 16 px root size: 14px is 0.875rem, 16px is 1rem, 18px is 1.125rem and 20px is 1.25rem. If your root size is different, type it in and the table updates.

Is the px to rem conversion the same on every site?

Only if the root font size is the same. The conversion divides by the html element's font size, which is 16px by default. Sites that set it to 62.5% get a 10px root, so 16px is 1.6rem there. Type your root size to get the right table.

What is the difference between rem and em?

rem is relative to the root element's font size, em to the font size of the parent element. em values can compound when elements are nested.

Related tools