At the default root font size of 16px, 40px is exactly 2.5rem.
Calculation based on a root font-size of 16 pixels.
How to convert 40px to rem
To convert pixels to rem, divide the pixel value by the root font size: rem = px ÷ 16. For 40px that is 40 ÷ 16 = 2.5rem.
40px is a large size, common for headings, section padding and generous layout gaps. It is often used for large headings and section padding.
40px at different root font sizes
| Root font size | Input | Result |
|---|---|---|
| 10px | 40px | 4rem |
| 12px | 40px | 3.3333rem |
| 14px | 40px | 2.8571rem |
| 15px | 40px | 2.6667rem |
| 16px | 40px | 2.5rem |
| 18px | 40px | 2.2222rem |
| 20px | 40px | 2rem |
| 22px | 40px | 1.8182rem |
| 24px | 40px | 1.6667rem |
CSS examples
font-size: 2.5rem; /* 40px */
padding: 2.5rem;
margin-bottom: 2.5rem;
width: 2.5rem;The same values in pixels, if you need a fixed size:
font-size: 40px;
padding: 40px;Tailwind CSS equivalent
The default spacing scale has a step for 2.5rem: use classes like p-10, m-10, gap-10, w-10 and h-10.
Nearby values
Frequently Asked Questions
40px equals 2.5rem when the root font size is the browser default of 16px. The calculation is 40 ÷ 16 = 2.5.
2.5rem equals 40px at a 16px root font size (2.5 × 16 = 40).
Yes. If the root font size is 18px, 40px equals 2.2222rem, and at 20px it equals 2rem. The pixel value itself never changes, only the rem equivalent. Use the base font size field above to try any value.
Prefer rem for font sizes, spacing and layout so they respect the user's browser font settings and scale for accessibility. Use px for details that should never scale, such as 1px borders or fixed icon sizes.
