frontendhack-logo
40px = 2.5rem

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 sizeInputResult
10px40px4rem
12px40px3.3333rem
14px40px2.8571rem
15px40px2.6667rem
16px40px2.5rem
18px40px2.2222rem
20px40px2rem
22px40px1.8182rem
24px40px1.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

PixelsREM
40px2.5rem
2px0.125rem
3px0.1875rem
4px0.25rem
5px0.3125rem
6px0.375rem

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.