Table of Contents
Root font size
px
Browsers default to 16px.
PX → REM
px
REM
1.5rem
REM → PX
rem
Pixels
24px
Conversion table (base 16px)
| Pixels | REM | Tailwind spacing |
|---|---|---|
| 1px | 0.0625rem | – |
| 2px | 0.125rem | – |
| 4px | 0.25rem | 1 |
| 8px | 0.5rem | 2 |
| 10px | 0.625rem | – |
| 12px | 0.75rem | 3 |
| 14px | 0.875rem | – |
| 16px | 1rem | 4 |
| 18px | 1.125rem | – |
| 20px | 1.25rem | 5 |
| 24px | 1.5rem | 6 |
| 28px | 1.75rem | 7 |
| 32px | 2rem | 8 |
| 40px | 2.5rem | 10 |
| 48px | 3rem | 12 |
| 56px | 3.5rem | 14 |
| 64px | 4rem | 16 |
| 80px | 5rem | 20 |
| 96px | 6rem | 24 |
rem = px ÷ root font size. Using rem lets text and spacing scale when a visitor changes their browser font size, which helps accessibility. em is relative to the parent element instead of the root.
How to Convert PX to REM
rem = px ÷ root font size. With the browser default of 16px, 24px = 1.5rem, 14px = 0.875rem and 32px = 2rem. Change the base size if your site sets a different font size on the html element.
Why Use REM in CSS
- Text and spacing scale when visitors change their browser font size, which improves accessibility.
- You can resize a whole design by changing one root value.
- Frameworks such as Tailwind CSS use rem for spacing (1 unit = 0.25rem = 4px at 16px).
Working on responsive images too? Use the aspect ratio calculator.
Frequently Asked Questions
How many pixels is 1rem?
16px by default, because browsers set the root font size to 16px.
What is the difference between rem and em?
rem is relative to the root (html) font size; em is relative to the font size of the parent element, so em values compound when nested.
