frontendhack-logo
4px = 0.25rem

At the default root font size of 16px, 4px is exactly 0.25rem.

Calculation based on a root font-size of 16 pixels.

How to convert 4px to rem

To convert pixels to rem, divide the pixel value by the root font size: rem = px ÷ 16. For 4px that is 4 ÷ 16 = 0.25rem.

4px is a very small size, typically used for borders, hairlines, icon gaps and fine detail. It is often used for the smallest step of a 4px spacing grid.

4px at different root font sizes

Root font sizeInputResult
10px4px0.4rem
12px4px0.3333rem
14px4px0.2857rem
15px4px0.2667rem
16px4px0.25rem
18px4px0.2222rem
20px4px0.2rem
22px4px0.1818rem
24px4px0.1667rem

CSS examples

font-size: 0.25rem; /* 4px */
padding: 0.25rem;
margin-bottom: 0.25rem;
width: 0.25rem;

The same values in pixels, if you need a fixed size:

font-size: 4px;
padding: 4px;

Tailwind CSS equivalent

The default spacing scale has a step for 0.25rem: use classes like p-1, m-1, gap-1, w-1 and h-1.

Nearby values

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

Frequently Asked Questions

4px equals 0.25rem when the root font size is the browser default of 16px. The calculation is 4 ÷ 16 = 0.25.

0.25rem equals 4px at a 16px root font size (0.25 × 16 = 4).

Yes. If the root font size is 18px, 4px equals 0.2222rem, and at 20px it equals 0.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.