AyeCalc
All tools
Developer units

PX to EM Converter

Convert fixed pixel measurements to context-relative em units. Set the element font size used by your component to get the correct local CSS value.

Instant resultAdjustable assumptionsNo data sent
Instant conversion

px em

Runs in your browser
ems1em

Result rounded to a maximum of six decimal places.

Conversion ruleem = px ÷ element font size

At a 16px element size: em = px ÷ 16.

01
Method

How to convert pixels to ems

Divide the pixel value by the relevant element or parent font size. With a 16px context, 16px equals 1em and 24px equals 1.5em.

Formulaem = px ÷ element font size

At a 16px element size: em = px ÷ 16.

02
Worked example

Convert 24 px to em

Apply the conversion rule to 24 pixels. Using the default settings, the result is 1.5 em.

24 px1.5 em

Default context: element font size 16px.

03
Quick reference

px to em conversion table

These pre-calculated values use the same formula and default settings as the converter above.

Common pixels to ems conversions
pixels (px)ems (em)
1 px0.0625 em
2 px0.125 em
4 px0.25 em
8 px0.5 em
10 px0.625 em
12 px0.75 em
14 px0.875 em
16 px1 em
18 px1.125 em
20 px1.25 em
24 px1.5 em
32 px2 em
48 px3 em
64 px4 em
80 px5 em
96 px6 em
04
Practical use

Code and calculation snippets

Reuse the same conversion in a stylesheet or application. Keep contextual font sizes configurable when working with relative CSS units.

CSS
.component {
  font-size: 16px;
  padding: 1.5em; /* 24px */
}
JavaScript
const em = pixels / elementFontSize;
Sass
@use "sass:math";
@function em($px, $context: 16) {
  @return math.div($px, $context) * 1em;
}
05
Interpretation

Using the result accurately

EM is helpful when a component's spacing, icons, or child typography should scale with that component. Check which ancestor establishes the font-size context for the property you are converting.

Important limitation

EM is context-dependent and can compound when nested font sizes are expressed in em. The same em value can therefore resolve to different pixel sizes in different components.

Reference: W3C CSS Values and Units: font-relative lengths.

Common questions

PX to EM Converter FAQ

Short answers about the formula, assumptions, and displayed precision.

How do I convert pixels to ems?

Divide the pixel value by the relevant element or parent font size. With a 16px context, 16px equals 1em and 24px equals 1.5em. For example, 24 px converts to 1.5 em using the default settings.

What formula does this px-to-em converter use?

em = px ÷ element font size. At a 16px element size: em = px ÷ 16.

What assumptions does the calculator make?

The calculator starts with 16px for the element font size. You can change it to match your CSS.

How many decimal places should I use?

The calculator shows up to six decimal places and removes unnecessary trailing zeros. Keep more precision for further calculations, then round the final value to suit your measurement or design system.