Home Text Tools Math & Numbers Developer Tools Date & Time Image Tools Blog
PX ↔ REM / EM Converter

Why rem Beats px for Accessible, Scalable Font Sizes

Learn how rem units respect a user's browser font size setting, how to convert px values, and which CSS properties should or should not use rem.

Set your body text to 16px and it will look fine on your screen. But a visitor who raised their browser's default font size to 20px for easier reading will see no change at all. Pixels ignore that preference, and rem units respect it. This guide shows how to switch and convert your values safely.

PX ↔ REM / EM Converter FREE online toolRuns in your browser. No sign-up, nothing to install. Open the tool

What actually happens with px and rem

A rem is relative to the font size of the root html element. Browsers default that to 16px, so 1rem equals 16px, 1.5rem equals 24px and 0.875rem equals 14px. If a user changes the default font size in their browser settings, every rem value scales with it.

Pixel font sizes are fixed. Browser zoom still scales them, but the separate default font size setting does not, and many people with low vision rely on that setting.

Converting your existing values

The formula is simple: divide the pixel value by the root font size. At a 16px root, 12px is 0.75rem, 18px is 1.125rem, 20px is 1.25rem and 32px is 2rem. Doing this for dozens of values is tedious, which is where a converter saves time, especially with a bulk list.

  1. Leave the html root font size unset, or set it as font-size: 100% so the user's preference is preserved.
  2. List every font-size in your stylesheet in pixels.
  3. Convert each with the PX to REM Converter using a base of 16.
  4. Replace the declarations and test at your normal size.
  5. Raise the browser default to 24px and check that the layout still holds.

Avoid the 62.5% trick unless you know the cost

A common shortcut sets html to 62.5% so that 1rem equals 10px. It makes the math easy, but if you then write body text in plain px elsewhere or forget to reset the body size, you can end up with tiny text. If you use it, set body to 1.6rem explicitly. Keeping 100% and converting properly is safer for accessibility.

What to convert and what to leave

  • Font sizes: use rem.
  • Line height: use a unitless number like 1.5.
  • Padding and margin on text containers: rem or em so spacing grows with text.
  • Borders and thin hairlines: px is fine.
  • Media query breakpoints: em works more reliably across browsers when users change font size.

A quick reference table at the 16px root

These conversions cover most stylesheets, so you can sanity check results at a glance.

  • 12px is 0.75rem, handy for small captions.
  • 14px is 0.875rem, common for secondary text.
  • 16px is 1rem, the default body size.
  • 20px is 1.25rem, good for lead paragraphs.
  • 24px is 1.5rem and 32px is 2rem, typical for headings.

Handling em and nested sizes

The em unit is relative to the parent element's font size, so nested elements compound: a 1.2em inside another 1.2em becomes 1.44 times the base. That is why rem is usually safer for font sizes, while em suits padding on a button that should scale with its own text. When converting a legacy stylesheet, convert top-level sizes first and then review components that rely on em.

Test like a user

Open your browser settings, increase the default font size, and reload the page. Look for clipped text in fixed-height boxes, overlapping buttons and horizontal scrolling. Fixed heights are the usual culprit; replace them with min-height or let content decide.

WCAG success criterion 1.4.4 asks that text can be resized up to 200 percent without loss of content, so this test directly supports compliance.

Try the free PX ↔ REM / EM Converter
Runs in your browser. No sign-up, nothing to install.

Comments (0)

No comments yet. Be the first to share a thought.