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.
| PX | REM | Tailwind 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.
How to convert px to rem
- Check the root font size. It is 16px unless your CSS changes the font size of the
htmlelement. - Type a pixel value into the Pixels field to get rem, or type into the REM field to get pixels.
- 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)
| PX | REM | PX | REM | PX | REM |
|---|---|---|---|---|---|
| 1px | 0.0625rem | 14px | 0.875rem | 36px | 2.25rem |
| 2px | 0.125rem | 16px | 1rem | 40px | 2.5rem |
| 4px | 0.25rem | 18px | 1.125rem | 48px | 3rem |
| 6px | 0.375rem | 20px | 1.25rem | 56px | 3.5rem |
| 8px | 0.5rem | 24px | 1.5rem | 64px | 4rem |
| 10px | 0.625rem | 28px | 1.75rem | 72px | 4.5rem |
| 12px | 0.75rem | 32px | 2rem | 96px | 6rem |
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
| Unit | Relative to | Good for |
|---|---|---|
px | Nothing (fixed) | Borders, shadows, fine details |
rem | Root (html) font size | Font sizes, spacing, layout |
em | The element's own font size | Padding 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.