PX to EM Converter (Pixels to Em)

Convert CSS pixels to relative EM units in real time. Calculate context-aware margins, padding, line-heights, and component scaling based on parent container font sizes.

16px is the default browser root font-size. Change this if your site sets a different root (or parent, for em) font-size.
Result Live
Result

How to convert PX to EM

To convert pixels (px) to ems (em), divide the target pixel size by the parent element's base font size.

Contextual Conversion Formula
EM = Pixels ÷ Parent Font Size   Example: 24px ÷ 16px (default parent) = 1.5em

While rem units always evaluate against the root (<html>) element, em units inherit relative to their immediate parent container. If a parent container has a font size set to 20px, then 1em = 20px inside that specific sub-tree.

PX to EM conversion table (Default 16px Base)

Standard CSS design system pixel metrics converted to EM values assuming a 16px default parent context:

Pixels (px) Em (16px Base) Em (20px Parent) Typical Web Design Use Case
4px0.25em0.20emTight icon padding / subtle border-radius
8px0.5em0.40emStandard element margin / small gap
12px0.75em0.60emForm caption / footer micro-copy
14px0.875em0.70emSecondary text / UI button labels
16px1.0em0.80emStandard body copy baseline (1rem = 1em)
20px1.25em1.0emSubheadings (H3 / H4) / card title
24px1.5em1.20emSection headings (H2)
32px2.0em1.60emHero headlines (H1) / modal titles
48px3.0em2.40emLarge display titles / landing hero banners

When to use EM vs REM vs PX

Choosing between absolute and relative CSS units depends on component portability and design intent:

Unit Inheritance Source Best Suited For Key Advantage
EM Parent Container / Current Element Component-level padding, icons, button padding, line-height Scales relative to local typography changes
REM Root Element (<html>) Site-wide typography, main layout grids, structural margins Avoids unwanted compounding bugs across nested wrappers
PX Absolute Hardcoded Value Borders, subtle drop shadows, media queries Exact pixel-perfect rendering regardless of parent size

Understanding the EM compounding trap

Because em units multiply down the DOM tree, nesting multiple relative containers can produce unexpected sizing spikes. For example:

  • Parent container: font-size: 1.2em; (19.2px)
  • Child container: font-size: 1.2em; (23.04px)
  • Grandchild container: font-size: 1.2em; (27.65px)

To prevent unwanted compounding while maintaining responsive flexibility, use PX to REM for global font sizing and restrict em to local padding or icon alignment. Reverse your values anytime using our EM to PX Converter.

Frequently asked questions

How do I convert px to em?

Divide the pixel value by the parent element's font size (e.g., 20px ÷ 16px = 1.25em).

What is the difference between em and rem?

rem always resolves against the single root (<html>) font size (typically 16px), whereas em resolves relative to its immediate parent element's font size.

How many em is 16px?

With a standard 16px base font size, 16px equals exactly 1.0em (16 ÷ 16 = 1.0).

How do I convert em back to px?

Multiply the em value by the parent element's base font size, or use our EM to PX Converter.