frontendhack-logo
2px = 0.125rem

At the default root font size of 16px, 2px is exactly 0.125rem.

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

How to convert 2px to rem

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

2px is a very small size, typically used for borders, hairlines, icon gaps and fine detail. It is often used for thin borders, outlines and tiny gaps.

2px at different root font sizes

Root font sizeInputResult
10px2px0.2rem
12px2px0.1667rem
14px2px0.1429rem
15px2px0.1333rem
16px2px0.125rem
18px2px0.1111rem
20px2px0.1rem
22px2px0.0909rem
24px2px0.0833rem

CSS examples

font-size: 0.125rem; /* 2px */
padding: 0.125rem;
margin-bottom: 0.125rem;
width: 0.125rem;

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

font-size: 2px;
padding: 2px;

Tailwind CSS equivalent

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

Nearby values

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

Frequently Asked Questions

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

0.125rem equals 2px at a 16px root font size (0.125 × 16 = 2).

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