How to convert PX to REM
Divide the pixel value by the root font size. Most browsers use a 16px root font size unless the website changes it.
rem = px ÷ 16px = rem × 16For example, 24px ÷ 16px = 1.5rem. To convert back, 1.5rem × 16px = 24px.
PX to REM conversion table
Common pixel values converted with the standard 16px base font size.
| PX | REM (16px) | CSS |
|---|---|---|
| 1px | 0.0625rem | font-size: 0.0625rem; |
| 2px | 0.125rem | font-size: 0.125rem; |
| 4px | 0.25rem | font-size: 0.25rem; |
| 8px | 0.5rem | font-size: 0.5rem; |
| 10px | 0.625rem | font-size: 0.625rem; |
| 12px | 0.75rem | font-size: 0.75rem; |
| 14px | 0.875rem | font-size: 0.875rem; |
| 16px | 1rem | font-size: 1rem; |
| 18px | 1.125rem | font-size: 1.125rem; |
| 20px | 1.25rem | font-size: 1.25rem; |
| 24px | 1.5rem | font-size: 1.5rem; |
| 32px | 2rem | font-size: 2rem; |
| 40px | 2.5rem | font-size: 2.5rem; |
| 48px | 3rem | font-size: 3rem; |
| 64px | 4rem | font-size: 4rem; |
| 80px | 5rem | font-size: 5rem; |
| 96px | 6rem | font-size: 6rem; |
Tailwind CSS spacing reference
Tailwind's default spacing scale commonly maps these PX and REM values to padding, margin, and gap utilities.
| PX | REM | Tailwind |
|---|---|---|
| 4px | 0.25rem | p-1 / m-1 / gap-1 |
| 8px | 0.5rem | p-2 / m-2 / gap-2 |
| 12px | 0.75rem | p-3 / m-3 / gap-3 |
| 16px | 1rem | p-4 / m-4 / gap-4 |
| 20px | 1.25rem | p-5 / m-5 / gap-5 |
| 24px | 1.5rem | p-6 / m-6 / gap-6 |
| 32px | 2rem | p-8 / m-8 / gap-8 |
| 40px | 2.5rem | p-10 / m-10 / gap-10 |
| 48px | 3rem | p-12 / m-12 / gap-12 |
| 64px | 4rem | p-16 / m-16 / gap-16 |
| 96px | 6rem | p-24 / m-24 / gap-24 |
PX vs REM
PX is a fixed absolute unit, while REM is relative to the root html font size.
PX and REM FAQ
How many REM is 16px?
At the standard 16px base font size, 16px equals 1rem.
How do I convert PX to REM?
Divide the pixel value by the root font size. With a 16px base, 32px divided by 16 equals 2rem.
Should I use REM or PX in CSS?
REM is generally useful for scalable typography and spacing, while PX remains practical for fine details such as thin borders. Choose based on the design requirement.
What if my base font size is not 16px?
Enter your actual root font size in the calculator. For a 10px base, 20px equals 2rem; for a 14px base, 20px is about 1.4286rem.
