CSS Unit Converter - PX to REM and REM to PX

Convert between pixels and rem units for responsive web design. Includes a reference table with common font sizes.

px (browser default is 16px)
10px
0.625rem
Extra Small
12px
0.75rem
Small
14px
0.875rem
Body Small
16px
1rem
Body (Default)
18px
1.125rem
Body Large
20px
1.25rem
H6
24px
1.5rem
H5
30px
1.875rem
H4
36px
2.25rem
H3
48px
3rem
H2
60px
3.75rem
H1
72px
4.5rem
Display

Why Use REM Units?

REM (root em) units are relative to the root element's font size, making your designs more accessible and scalable. When users change their browser's default font size, REM-based layouts adjust proportionally, improving readability for users with visual impairments.

PX vs REM vs EM

  • PX (Pixels): Fixed size, doesn't scale with user preferences.
  • REM (Root EM): Relative to html element font size, consistent throughout page.
  • EM: Relative to parent element, can compound in nested elements.

The 62.5% Trick

Many developers set html { font-size: 62.5%; } to make 1rem equal 10px (since 62.5% of 16px = 10px). This simplifies mental math:

  • 14px = 1.4rem
  • 16px = 1.6rem
  • 20px = 2rem

Best Practices for Responsive Typography

  • Use REM for font sizes, margins, and padding.
  • Use pixels for borders, box shadows, and fine details.
  • Set a reasonable base size (16px is standard).
  • Use media queries to adjust the root font size for different screen sizes.
  • Test with browser zoom and font size settings.

CSS Custom Properties with REM

Combine REM with CSS variables for a flexible design system:

:root {
  --font-sm: 0.875rem;  /* 14px */
  --font-base: 1rem;    /* 16px */
  --font-lg: 1.125rem;  /* 18px */
  --font-xl: 1.5rem;    /* 24px */
  --spacing-4: 0.25rem; /* 4px */
  --spacing-8: 0.5rem;  /* 8px */
}

Accessibility Benefits

Using REM units respects user preferences. Users who set larger default font sizes (common for low vision) will see your entire layout scale appropriately, maintaining proportions and readability.