Dev ToolsMarch 30, 2026

Pixel to Em Converter Guide: CSS Units, Accessibility & Responsive Design

By The hakaru Team·Last updated March 2026

Quick Answer

  • *1em = 16px at the default browser font size. Divide any pixel value by 16 to get em/rem.
  • *Em is relative to the parent's font size; rem is relative to the root html element.
  • *Using relative units respects user font-size preferences — ~3% of users change their default.
  • *Use rem for font sizes and spacing, px for borders and shadows.

Understanding CSS Units: px, em, and rem

CSS offers multiple length units, but three dominate modern web development: px (pixels), em (relative to parent font size), and rem (relative to root font size). Choosing the right one affects accessibility, responsiveness, and maintainability.

According to the W3C CSS Values specification, 1px equals 1/96th of an inch in the CSS reference pixel model. But on high-DPI screens, one CSS pixel may map to 2–4 physical device pixels. The key point: CSS pixels are a consistent, absolute unit within the browser — they don't scale with user preferences.

The Conversion Formula

The math is simple:

em value = pixel value ÷ parent font size in pixels

At the default browser font size (16px for all major browsers), the most common conversions are:

PixelsEm / Rem (base 16px)Common Use
10px0.625Small captions
12px0.75Fine print, labels
14px0.875Secondary text
16px1.0Body text (browser default)
18px1.125Large body / intro text
20px1.25H4 headings
24px1.5H3 headings
32px2.0H2 headings
48px3.0H1 / hero text

Em vs Rem: The Compounding Problem

The critical difference: em compounds through nested elements, while rem does not.

If you set a container to font-size: 1.25em (20px) and a child inside it to font-size: 1.25em, that child computes to 1.25 × 20 = 25px — not the 20px you might expect. Nest three levels deep and you get 31.25px. This compounding behavior is the number one source of unexpected sizing bugs in CSS.

Rem avoids this entirely because it always references the root html element. According to the 2025 State of CSS survey by Lea Verou and the Chrome team, 72% of developers now prefer rem over em for font sizing, up from 58% in 2022.

Why Relative Units Matter for Accessibility

About 3.1% of web usersmodify their browser's default font size, according to data published by the Web Almanac (HTTP Archive, 2024 edition). That translates to roughly 150 million people globally. Many of these users have low vision and rely on a larger base font to read comfortably.

When you set font sizes in pixels, the text stays the same size regardless of user preferences. A user who sets their browser to 20px default font size won't see any change on a px-based site. With rem, all text scales proportionally.

The WCAG 2.2 Success Criterion 1.4.4 requires that text can be resized up to 200% without loss of content or functionality. Using rem makes this nearly automatic. According to WebAIM's 2025 Million Home Pages report, 83.6% of homepages had detectable WCAG failures, and improper text scaling was among the top 10 issues.

When to Use Each Unit

UnitBest ForAvoid For
remFont sizes, padding, margins, spacing, media queriesBorder widths, box shadows
emComponent-internal spacing that should scale with local font size (e.g., button padding)Font sizes on nested elements
pxBorders, box shadows, outlines, fixed-size imagesFont sizes, layout widths on text-heavy pages

The 62.5% trick — setting html font-size to 62.5% so that 1rem = 10px — was popular for years. According to Josh Comeau's 2024 CSS analysis, this pattern is declining because it forces you to override font-size on the body element and can confuse third-party components that expect the 16px default.

Practical Conversion Tips

Use CSS Custom Properties

Define your spacing scale in rem using CSS custom properties. This gives you the readability of named tokens with the accessibility of relative units. For example: --space-sm: 0.5rem; --space-md: 1rem; --space-lg: 1.5rem.

Media Queries in Em

Safari has historically handled em-based media queries more reliably than rem-based ones. According to a 2024 Zach Leatherman test, em-based breakpoints also respond to user font-size changes, meaning a user with a 20px base font triggers your “tablet” breakpoint sooner — giving them more breathing room. This is generally considered an accessibility win.

Tailwind CSS and Rem

Tailwind CSS uses rem for nearly all its utility classes by default. The class text-base is 1rem (16px), text-lg is 1.125rem (18px), and so on. According to the 2025 npm download stats, Tailwind is installed on over 12 million projects, making rem the de facto standard in utility-first CSS.

Convert pixel values to em and rem instantly

Use our free Pixel to Em Converter →

Frequently Asked Questions

How do I convert pixels to em?

Divide the pixel value by the parent element's font size. If the parent font size is the browser default of 16px, then 1em = 16px. So 24px ÷ 16 = 1.5em. For rem, always divide by the root (html) font size, which is typically 16px.

What is the difference between em and rem in CSS?

Em is relative to the font size of the parent element, so it compounds when elements are nested. Rem is relative to the root (html) element's font size, so it stays consistent regardless of nesting depth. Most modern CSS favors rem for predictability.

Why should I use em or rem instead of pixels?

Using em or rem respects user browser settings for font size, which is critical for accessibility. About 3% of users change their default font size. Pixels override this preference, making text harder to read for users with low vision. The WCAG 2.2 guidelines recommend relative units for text sizing.

Is 1em always 16px?

No. 1em equals the computed font size of the parent element. The browser default is 16px, so 1em = 16px at the root level. But if a parent element has font-size: 20px, then 1em inside that element equals 20px. This is why rem (root em) is often preferred — it always refers to the html element's font size.

When should I still use pixels in CSS?

Pixels are appropriate for elements that should not scale with font size: borders (1px solid), box shadows, and fixed-size images or icons. Media query breakpoints can use either px or em — em-based breakpoints scale with user font size preferences, which some developers prefer for accessibility.