PX to REM Converter

Convert px to rem and rem to px at any root font size. See a full conversion table with Tailwind CSS values, and convert every px value in your CSS at once.

16px is the default in every browser. Change it if your html element uses a different font size.

Result

Converted CSS

                        
Conversion table (16px base)
PXREMTailwind CSS

Convert Pixels to REM Online

Designs are usually measured in pixels, but accessible CSS uses rem so that layouts grow when people increase their browser font size. This PX to REM converter turns pixel values into rem (and back) instantly, for the default 16px root font size or any other base.

Paste a whole block of CSS to convert every px value at once, with an option to keep 1px borders. A conversion table shows the most common sizes with their rem values and the matching Tailwind CSS classes.

Pixel value converted to rem24px1.5remPX to REMConverter

How to convert px to rem

  1. Check the root font size. It is 16px unless your CSS changes the font size of the html element.
  2. Type a pixel value into the Pixels field to get rem, or type into the REM field to get pixels.
  3. Copy the result, or paste a CSS snippet to convert all its px values in one go.

PX to REM formula

One rem equals the font size of the root (html) element. With the browser default of 16px:

rem = px ÷ 16  and  px = rem × 16

So 24px is 24 ÷ 16 = 1.5rem, 14px is 0.875rem and 2rem is 32px. If the root font size is 10px (a common trick using html { font-size: 62.5%; }), divide by 10 instead: 24px = 2.4rem.

PX to REM conversion table (16px base)

PXREMPXREMPXREM
1px0.0625rem14px0.875rem36px2.25rem
2px0.125rem16px1rem40px2.5rem
4px0.25rem18px1.125rem48px3rem
6px0.375rem20px1.25rem56px3.5rem
8px0.5rem24px1.5rem64px4rem
10px0.625rem28px1.75rem72px4.5rem
12px0.75rem32px2rem96px6rem

Why use rem instead of px?

  • Accessibility: people with low vision often raise the default font size in their browser settings. Sizes in rem follow that setting; sizes in px ignore it. WCAG 1.4.4 asks that text can be resized to 200% without breaking the layout.
  • Consistent scaling: change the root font size once and every rem-based spacing and font size scales with it.
  • Predictable: unlike em, rem is always relative to the root, so nested elements do not compound.
  • When px is fine: hairline borders (1px), box shadows and some media details often stay in px on purpose.

REM vs EM vs PX

UnitRelative toGood for
pxNothing (fixed)Borders, shadows, fine details
remRoot (html) font sizeFont sizes, spacing, layout
emThe element's own font sizePadding of buttons, icons sized with text, media queries

REM in Tailwind CSS

Tailwind CSS is built on rem. One spacing unit is 0.25rem (4px at the default size), so p-4 is 1rem (16px) and mt-6 is 1.5rem (24px). Font sizes are rem as well: text-sm is 0.875rem (14px), text-base 1rem and text-lg 1.125rem (18px). For any other size use an arbitrary value such as p-[1.125rem].

See the spacing utilities in the Tailwind padding and Tailwind margin docs.

Frequently Asked Questions

Common questions about converting px to rem.

1rem is 16px in every browser by default, because the default root font size is 16px. If your CSS changes the html font size, 1rem changes with it.

Divide the pixel value by the root font size. At the default 16px, 24px ÷ 16 = 1.5rem and 12px ÷ 16 = 0.75rem.

Multiply by the root font size: 1.25rem × 16 = 20px. Type a value into the REM field above to convert it.

14px is 0.875rem at the default 16px root font size. That is the size of text-sm in Tailwind CSS.

Use rem for font sizes, spacing and layout so they respect the user’s font size. Keep px for things that should not scale, such as 1px borders and box shadows.

Setting html { font-size: 62.5%; } makes 1rem equal 10px, so 24px is 2.4rem. It makes mental math easier, but you then need to set a comfortable body font size again.

Yes. Paste CSS into the snippet box and every px value is converted to rem. Tick or untick the option to keep 1px values unchanged.