frontendhack-logo
5px = 0.3125rem

At the default root font size of 16px, 5px is exactly 0.3125rem.

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

How to convert 5px to rem

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

5px is a very small size, typically used for borders, hairlines, icon gaps and fine detail.

5px at different root font sizes

Root font sizeInputResult
10px5px0.5rem
12px5px0.4167rem
14px5px0.3571rem
15px5px0.3333rem
16px5px0.3125rem
18px5px0.2778rem
20px5px0.25rem
22px5px0.2273rem
24px5px0.2083rem

CSS examples

font-size: 0.3125rem; /* 5px */
padding: 0.3125rem;
margin-bottom: 0.3125rem;
width: 0.3125rem;

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

font-size: 5px;
padding: 5px;

Tailwind CSS equivalent

0.3125rem is not part of the default Tailwind scale, but you can use an arbitrary value such as p-[0.3125rem] or text-[0.3125rem].

Nearby values

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

Frequently Asked Questions

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

0.3125rem equals 5px at a 16px root font size (0.3125 × 16 = 5).

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