PX to EM Converter

Convert pixels to em relative to any parent font size, and see how nested em values compound compared with rem.

Runs in your browser

Convert

px

The computed font-size of the element the em is relative to.

px

Separate several values with spaces

em

Separate several values with spaces

24px = 1.5em

PX to EM table

Based on a parent font size of 16px.

PixelsEMCopy
1px0.0625em
2px0.125em
4px0.25em
6px0.375em
8px0.5em
10px0.625em
12px0.75em
13px0.8125em
14px0.875em
15px0.9375em
16px1em
18px1.125em
20px1.25em
22px1.375em
24px1.5em
26px1.625em
28px1.75em
30px1.875em
32px2em
36px2.25em
40px2.5em
44px2.75em
48px3em
56px3.5em
64px4em
72px4.5em
80px5em
96px6em

Compounding: em vs rem

Each nested .item sets font-size: 1.25em. Em multiplies at every level; rem always starts from the root (assumed 16px here).

em / rem
Nesting level1.25em computes to1.25rem computes to
Level 120px20px
Level 225px20px
Level 331.25px20px
Level 439.0625px20px
Level 548.8281px20px

Bulk convert CSS (px → em)

Hairline borders and outlines usually stay in px so they never blur or vanish.

Rem and em in @media conditions always resolve against the browser default (usually 16px), not your root font size.

Converted CSS (em)

Converted CSS appears here as you type. Values are calculated with a 16px base.

What is an em in CSS?

An em is a length relative to a font size. For most properties — padding, margin, width, border-radius, letter-spacing — 1em equals the computed font size of the element itself. For the font-size property, 1em equals the font size of the parent, because the element’s own size is what is being calculated. The conversion is em = px ÷ context font size.

That makes em ideal for components that should scale as a unit. Give a button padding: 0.75em 1.25em and its padding grows automatically when you set a larger font-size on a "large" variant — no separate padding values needed. Icons sized in em match the text next to them, and media queries written in em respond to the user’s default font size.

The catch is compounding. Because each element’s em is based on its parent, nested elements that all use font-size: 1.2em get 1.2 × 1.2 × 1.2… larger at every level. Rem avoids this by always using the root. The demo in the tool shows the difference for any factor you choose.

How to use the PX to EM Converter

  1. Enter the parent font size — the computed font size of the element the em will be relative to (for padding and margin, the element’s own font size).
  2. Type a pixel value to get em, or type in the EM field to get pixels back. Space-separated values like 12 24 convert together.
  3. Look up common sizes in the chart and copy any result with one click.
  4. Use the compounding demo to check how nested em font sizes grow, and paste CSS into the bulk converter to switch a component from px to em.

Example

Nested lists where each level sets font-size: 1.25em, inside a 16px parent:

.list { font-size: 1.25em; }

<ul class="list">          <!-- 16 × 1.25 = 20px -->
  <li><ul class="list">    <!-- 20 × 1.25 = 25px -->
    <li><ul class="list">  <!-- 25 × 1.25 = 31.25px -->

/* With font-size: 1.25rem every level is 20px. */

EM vs REM: which one to use

  • Font sizes: prefer rem. It never compounds, so a component looks the same wherever it is placed. Convert with the PX to REM Converter.
  • Padding, gaps and icon sizes inside components: em is often better because spacing then scales with the component’s own text size — great for buttons with small, medium and large variants.
  • Media queries: em and rem behave identically there — both use the browser default font size — and both respect a user’s larger default text.
  • Line height: use a unitless number such as 1.5 instead of em. Unitless values are inherited as a ratio, while em values are inherited as a fixed computed length.

Frequently Asked Questions

What is the em equivalent of 24px?

With a 16px parent, 24px is 1.5em. With an 18px parent it is 1.3333em. Always divide by the font size of the element’s context, not the root.

Why is my em padding a different size than expected?

For padding and margin, em uses the element’s own computed font size, not the parent’s. A heading with font-size: 32px and padding: 1em gets 32px of padding. Enter the element’s font size as the context to convert accurately.

How do I stop em font sizes compounding?

Use rem for font-size, or reset nested elements with font-size: 1em (which keeps the parent size). Compounding only affects font-size chains; em-based padding is resolved against each element’s final font size.

Is em the same as percent?

For font-size, yes: 1.5em and 150% are identical. For other properties they differ — a percentage width or padding is relative to the containing block’s width, while em is relative to font size.