Skip to content

PX to REM Converter

Type a pixel value to get rem, or a rem value to get pixels, at the default 16px root or any root font size your stylesheet uses.

Runs in your browserFree, no sign-upLast reviewed

Settings

16px is the browser default unless html { font-size } changes it.

Results update automatically as you type.

Result

Input
24px
Result
1.5rem
Root font size
16px
Formula
24 ÷ 16

CSS

.element {
  font-size: 1.5rem;
}

Common values at a 16px root

pxremTypically used for
12px0.75remFine print, captions
14px0.875remSecondary text, labels
16px1remBody text
18px1.125remLead paragraphs
20px1.25remSmall headings
24px1.5remSection headings
32px2remPage headings
48px3remDisplay headings

Quick answers

How do I convert px to rem?
Divide the pixel value by the root font size, which is 16px by default. 16px is 1rem, 24px is 1.5rem, 32px is 2rem and 12px is 0.75rem.
How many pixels is 1rem?
16 pixels in every major browser by default. 1rem equals the font size of the html element, so it changes if a stylesheet sets html { font-size } or if the reader has chosen a larger or smaller default text size in their browser.
What is 16px in rem?
1rem at the default root. At other roots: 1.6rem at 10px, 0.8889rem at 18px and 0.8rem at 20px.
What is 14px in rem?
0.875rem at the default 16px root (14 / 16). With a 10px root it is 1.4rem.
What is 10px in rem?
0.625rem at the default 16px root. It is exactly 1rem only when the root font size has been set to 10px, for example with html { font-size: 62.5% }.
How do I convert rem to px?
Multiply the rem value by the root font size. At 16px, 1.5rem is 24px, 2.5rem is 40px and 0.875rem is 14px.
Is rem the same as em?
No. rem is always relative to the root html font size, so 1rem is the same everywhere on a page. em is relative to the font size of the element it is used on, so it changes with nesting.

What PX to REM Converter does

To convert px to rem, divide the pixel value by the root font size. Browsers set that root to 16px unless a stylesheet changes it, so 24px is 24 / 16 = 1.5rem and 1rem is 16px. This converter does the division for any value and any root, and flips to rem to px when you need the pixel size back. Results are rounded to four decimal places, so 17px shows as 1.0625rem and 24px at an 18px root shows as 1.3333rem. Alongside the answer you get the working (24 ÷ 16), a short CSS snippet, and a table of eight common type sizes from 0.75rem to 3rem, recalculated for your root.

PX to REM conversion chart (16px root)

Common pixel values and their rem equivalents at the browser default root font size.

PixelsREMPixelsREM
1px0.0625rem22px1.375rem
2px0.125rem24px1.5rem
4px0.25rem28px1.75rem
6px0.375rem30px1.875rem
8px0.5rem32px2rem
10px0.625rem36px2.25rem
11px0.6875rem40px2.5rem
12px0.75rem48px3rem
13px0.8125rem56px3.5rem
14px0.875rem64px4rem
15px0.9375rem72px4.5rem
16px1rem80px5rem
18px1.125rem96px6rem
20px1.25rem128px8rem

100px is 6.25rem. Every multiple of 4px gives a rem value that ends cleanly at 0.25, 0.5, 0.75 or a whole number, which is one reason spacing scales are built on 4px steps.

PX to REM formula

rem = px / root font size. px = rem x root font size.

The root font size is the computed font-size of the html element in pixels. With no CSS overriding it, that is 16. So 20px is 20 / 16 = 1.25rem, and 3rem is 3 x 16 = 48px. If your stylesheet has html { font-size: 18px }, divide by 18 instead: 24px becomes 1.3333rem. A percentage on html is a percentage of the browser default, so at the usual 16px, 62.5% is a 10px root and 112.5% is an 18px root. The tool shows the exact division it performed in the Formula row and rounds the answer to four decimal places.

PX to REM at 10px, 16px, 18px and 20px root font sizes

The same pixel value gives a different rem number at each root. Use the column that matches your html font-size.

Pixels16px root10px root18px root20px root
8px0.5rem0.8rem0.4444rem0.4rem
10px0.625rem1rem0.5556rem0.5rem
12px0.75rem1.2rem0.6667rem0.6rem
14px0.875rem1.4rem0.7778rem0.7rem
16px1rem1.6rem0.8889rem0.8rem
18px1.125rem1.8rem1rem0.9rem
20px1.25rem2rem1.1111rem1rem
24px1.5rem2.4rem1.3333rem1.2rem
32px2rem3.2rem1.7778rem1.6rem
40px2.5rem4rem2.2222rem2rem
48px3rem4.8rem2.6667rem2.4rem
64px4rem6.4rem3.5556rem3.2rem

Values in the 18px column are rounded to four decimal places. 0.4444rem at an 18px root is 7.9992px, close enough that the browser renders it as 8px.

REM to PX chart (16px root)

REMPixelsTypical use
0.0625rem1pxHairline borders
0.125rem2pxThick borders, focus rings
0.25rem4pxTight gaps, small radii
0.5rem8pxCompact padding
0.75rem12pxFine print, captions
0.875rem14pxSecondary text, labels
1rem16pxBody text
1.125rem18pxLead paragraphs
1.25rem20pxSmall headings
1.5rem24pxSection headings
2rem32pxPage headings
2.5rem40pxLarge headings
3rem48pxDisplay headings
4rem64pxSection spacing
5rem80pxLarge section spacing
6rem96pxHero spacing

Worked conversions

A 24px heading from a design file

Convert px to rem, Value 24, Root font size 16

1.5rem. Formula: 24 ÷ 16. CSS: font-size: 1.5rem;

An odd size that does not divide evenly

Convert px to rem, Value 17, Root font size 16

1.0625rem

A project using the 62.5% root

Convert px to rem, Value 24, Root font size 10

2.4rem

With a 10px root the rem value is the pixel value with the decimal point moved one place.

A site with an 18px base size

Convert px to rem, Value 24, Root font size 18

1.3333rem. The Common values table changes to 13.5px, 15.75px, 18px, 20.25px, 22.5px, 27px, 36px and 54px.

Reading a rem value back in pixels

Convert rem to px, Value 1.125, Root font size 16

18px. Formula: 1.125 × 16.

A negative margin

Convert px to rem, Value -8, Root font size 16

-0.5rem

When to use rem and when to keep px

Use rem for anything tied to reading: font sizes, the padding and margins around text, gaps between items, and max-widths for text columns. People can raise their browser's default font size, often because they need larger text. That setting changes what 1rem means, so a rem-based layout grows with them. A font-size written in px ignores the setting and stays the size the designer chose.

This is separate from page zoom. Zoom scales everything, px included. The default font size preference only reaches sizes written in relative units, which is why rem matters even though zoom exists.

Keep px for details that should not scale: a 1px border, a hairline divider, a precise shadow offset. Scaling those gives blurry fractional edges and helps nobody.

On the 62.5% trick: setting html { font-size: 62.5% } makes 1rem equal 10px so the arithmetic is easy. It still respects the reader's preference because it is a percentage, but any third-party component sized in rem on the assumption of a 16px root will render at 62.5% of its intended size. Leaving the root alone and converting the numbers avoids that.

How to get your result

  1. 1

    Set Convert to px → rem, or to rem → px for the reverse.

  2. 2

    Enter the number in Value. Decimals are accepted.

  3. 3

    Leave Root font size at 16 unless your CSS sets a different font-size on the html element, in which case enter that size in pixels.

  4. 4

    Read Result and Formula, copy the CSS, or look the size up in the Common values table beneath.

Common questions

Why is the default root font size 16px?
It is the default text size that desktop and mobile browsers ship with, and they have agreed on it for decades. It is a default, not a fixed value: readers can change it in browser settings, and a page can change it with CSS on the html element.
Can I convert several values at once?
No, the tool converts one value at a time. For a batch of common sizes use the conversion charts on this page, or the Common values table under the result, which recalculates eight standard sizes for whatever root you enter.
Does this also convert px to em?
The arithmetic is the same if you enter the reference font size as the Root font size. For font-size that is the parent element's size, and for other properties it is the element's own: 24px against 20px text is 1.2em. The output will still be labelled rem, so change the unit when you paste it.
How many decimal places should a rem value have?
Up to four is plenty, and that is what the tool gives. Browsers keep more precision internally, but the difference between 1.3333rem and 1.33333rem at an 18px root is under a thousandth of a pixel.
Should media query breakpoints use rem?
They can, and em or rem breakpoints scale with the reader's default font size. In media queries both units are based on the browser's default size, not on any font-size you set on html, so always divide by 16 there: 768px is 48em.
Why did my rem sizes change when I edited the html font size?
Because every rem on the page is a multiple of that one value. Changing html from 16px to 18px makes 1.5rem grow from 24px to 27px everywhere. That is the purpose of the unit: one setting rescales the whole design.
Does the CSS snippet only work for font-size?
The snippet uses font-size as an example property. The converted number is valid for any length: margin, padding, gap, width, border-radius and so on. Copy the value and use it wherever you need it.
What happens if I enter a root font size of 0?
The tool stops with a message that the root font size must be greater than zero, since dividing by zero has no answer. Any positive number works, including decimals.

Further reading

Looking for something else? Browse all css tools or see every tool.