40px → REM
40px to REM — 2.5rem at 16px Base
At the default browser root size of 16px, 40px equals
2.5rem. Formula: rem = px ÷ 16.
Last reviewed:
CSS snippet
.example {
font-size: 2.5rem; /* 40px at 16px root */
padding: 2.5rem;
} PX to REM formula
rem = px ÷ root font size
40px ÷ 16px = 2.5rem Worked example: To convert 40px at a 16px root, divide 40 by 16.
40 ÷ 16 = 2.5. Write font-size: 2.5rem;
instead of font-size: 40px; so
text scales when users enlarge their browser default font size.
Common use cases at 40px (2.5rem)
| Category | Tailwind / design use | CSS property example |
|---|---|---|
| Font size | text-4xl (2.5rem) | font-size: 2.5rem; |
| Spacing | p-10 | padding: 2.5rem; |
| Gap / margin | p-10 | gap: 2.5rem; |
Nearby pixel conversions
Also see 30px to rem
and 48px to rem
.
40px to REM FAQ
How do you convert 40px to rem?
Divide 40 by the root font size. At the default 16px base: 40 ÷ 16 = 2.5rem. Formula: rem = px ÷ root font size.
What is 40px in rem at 16px base?
At a 16px root font size, 40px equals exactly 2.5rem. This is the browser default unless your project or the user changes html { font-size }.
Should I use 2.5rem or 40px in CSS?
Use 2.5rem for typography and spacing that should scale with the user's root font-size preference — important for accessibility. Reserve 40px for fixed values like 1px borders or bitmap image dimensions.
How do I convert 2.5rem back to pixels?
Multiply 2.5rem by 16: 2.5 × 16 = 40px. Reverse formula: px = rem × root font size.
Where is 40px commonly used in web design?
40px (2.5rem) maps to text-4xl (2.5rem) in typical design systems. For Tailwind spacing, see p-10. Check the use-case table on this page for CSS property examples.
Full converter
PX to REM Converter — any value, custom base
Cheat sheet
PX to REM cheat sheet — 12px through 64px