ConverterHubsConverterHubs

PX to EM Converter — CSS Parent-Relative Unit Calculator

Unlike rem, which always anchors to the root element, em is relative to its immediate parent element's font size. This makes em powerful for self-contained components where spacing and typography should scale together — but dangerous when nested carelessly, because it compounds.

Convert pixel values to em units relative to your parent element's font size. Understand how em cascades and compounds in nested CSS. Essential for sizing buttons, padding, and inline elements that should scale proportionally with their container's text.

1em equals the parent element's font size.

Applying EM for Component-Level Scaling

When you set font-size: 1.5em on an element, the browser multiplies its parent's font-size by 1.5. If the parent is already 1.2em large, and you nest a 1.5em child inside, the result is 1.2 × 1.5 = 1.8em — not what you expected. This compounding behavior is the key reason rem was invented.

  1. 1Identify the parent element's computed font-size (or use 16px if unknown).
  2. 2Enter your desired pixel size into the input field.
  3. 3Use the resulting em value in your CSS — and watch for nesting that could cause compounding.

EM Relative to Parent Formula

EM divides the desired pixel size by the parent element's font-size. Unlike rem, this reference changes depending on where in the DOM the element lives.

EM = Desired PX ÷ Parent Element Font Size Nested EM compounds: 1.2em × 1.5em = 1.8em effective size

EM Compound Scaling Reference

This table shows how em values compound under nesting — a common source of unexpected font-size growth in CSS:

Nesting Level & EM ValueRendered Size (starting from 16px root)
Root: 16px16px
Level 1: 1.25em20px (16 × 1.25)
Level 2: 1.25em inside Level 125px (20 × 1.25)
Level 3: 1.25em inside Level 231.25px (25 × 1.25)
Level 1: 0.8em12.8px (16 × 0.8)
Level 2: 0.8em inside Level 110.24px (12.8 × 0.8)
Button: padding 1em (parent 16px)16px top/bottom padding
Button: padding 1em (parent 20px)20px top/bottom padding
Icon: 2em (parent 14px)28px icon
Icon: 2em (parent 18px)36px icon

EM Unit FAQs

rem is always relative to the root HTML font-size. em is relative to the parent element's font-size. rem is more predictable because it never compounds through nesting.

This is em compounding. If a parent sets font-size: 2em and you set the child to font-size: 2em too, the child renders at 4× the original base size. Use rem instead to avoid this.

Yes — for truly self-contained components like buttons, where you want padding, border-radius, and icon sizes to all scale proportionally with the component's own font-size. In that case, em creates a unified scaling system within the component.

EM units remain valuable for component-level scaling, but their compounding behavior demands careful use. Prefer rem for global typography and layout, and reserve em for self-contained component internals.

Related Tools