Skip to content
PictureToLink logoPictureToLink
Menu

Px to em converter

To convert px to em, divide the pixel value by the font size of the parent element: 24px inside a 16px parent is 1.5em. Em to px is the same sum backwards, so that 1.5em inside a 20px parent is 30px. Em values also stack, and three nested 1.2em levels turn 16px into 27.65px.

Change any value and the result updates as you type.

px
px

The computed font-size of the parent element, not the root

em

1.5em

24 ÷ 16 = 1.5

CSS
font-size: 1.5em;
Percent of the parent size
150%1em equals the parent font size, so em and % behave the same for font-size
If the parent were 20px instead
30pxThe same em value changes size whenever the parent does
px to em with a 16px parent
pxemPercent
8px0.5em50%
10px0.625em62.5%
12px0.75em75%
14px0.875em87.5%
16px1em100%
18px1.125em112.5%
20px1.25em125%
24px1.5em150%
28px1.75em175%
32px2em200%
36px2.25em225%
48px3em300%
64px4em400%

Calculated in your browser; nothing you type is sent or stored. Spotted a wrong result? Tell us.

By Ahsan Khowaja (CEO) · Updated 10 November 2026

On this page

How to use the px to em converter

  1. Choose px to em or em to px. Choose nested em font sizes to see what happens when em values stack.
  2. Type the pixel or em value you have.
  3. Type the parent font size. This is the computed font-size of the element that contains the one you're styling. For a top-level paragraph it is normally the 16px browser default. For a span inside an h2 it is whatever the h2 resolves to.

The third box is the difference between this tool and a rem converter. Rem always divides by the root (<html>) size. Em divides by the parent, so one pixel value gives different em values in different places on the page. If the root-relative unit is the one you want, use the px to rem converter.

The px to em formula

An em was originally the width of a capital M in metal type. In CSS it means "the current size", and for the font-size property the current size is the parent's, because an element can't be relative to the value it is defining (MDN: em). That gives two formulas:

  • em = px ÷ parent font size
  • px = em × parent size

Take the opening example: 24 ÷ 16 = 1.5em, and 12px inside an 18px parent is 12 ÷ 18 = 0.6667em. Going back, 1.25em in a 16px parent is 1.25 × 16 = 20px, and 0.75em in a 20px parent is 15px. Since 1em is exactly the parent size, em and percentages are interchangeable for font-size: 0.875em is the same as 87.5%.

Every other property (padding, margin, width, letter-spacing, border-radius) measures em against the element's own computed font size. Take a button with font-size: 1.25em; padding: 0.5em 1em inside a 16px parent. Its font is 20px and its padding is 10px by 20px, because the padding is measured against the button's own 20px and not the parent's 16px.

Em compounding: why nested em values multiply

Suppose a stylesheet says li { font-size: 1.2em } and one list sits inside another. The inner items are 1.2em of the outer items, which were already 1.2em of their own parent. Starting from 16px:

LevelWorkingComputed size
11.2em × 16px19.2px
21.2em × 19.2px23.04px
31.2em × 23.04px27.65px

Three levels deep the text is 16 × 1.2³ = 27.648px, which is 73% bigger than the body, though every rule only asked for "a bit larger". Values below 1 shrink the same way. small { font-size: 0.8em } nested twice gives 16 × 0.8² = 10.24px, below the size most people can read comfortably.

The nested em mode shows each level, so you can see where a size went wrong. Its "same value in rem" row shows what rem would have given you. Rem multiplies the root once and never compounds.

Px to em table at a 16px parent

pxemPercentNotes
8px0.5em50%Half the parent
10px0.625em62.5%
12px0.75em75%Common caption size
13px0.8125em81.25%
14px0.875em87.5%Common secondary text size
16px1em100%Equal to the parent
18px1.125em112.5%
20px1.25em125%
24px1.5em150%
28px1.75em175%
32px2em200%Twice the parent
48px3em300%

When the parent happens to be 16px, these numbers are identical to a px to rem table, and that is why the two units get confused so often. Change the parent box to 20px or 14px and every row moves. A rem table would stay as it is.

Em vs rem: which one to use

Use rem when a size should be the same wherever it appears on the page: body text, headings, the spacing scale, container widths. Use em when a size should follow the text next to it, so that one rule works at every size:

  • Em for padding and margin inside components. padding: 0.5em 1em on a button gives a small button small padding and a large button large padding from a single rule.
  • Em for icons that sit beside text. width: 1em; height: 1em keeps an SVG icon the same height as the letters.
  • Em for letter-spacing and text-indent, which are typographic measures and should scale with the glyphs.
  • Rem for font-size on almost everything, so nested components don't drift in size.

Mixing the two up is the usual cause of "why is this text huge inside the sidebar" bugs. It also changes how you read someone else's stylesheet. Converting rem to px in CSS never depends on nesting, so 0.75rem is 12px at the default root wherever it appears (0.75 rem in px is always 0.75 × root). With 0.75em you need to know the parent size before you can say what it is.

Em in media queries

Inside @media, em does not refer to any element's parent, because there is no element yet. It refers to the browser's initial size, 16px by default, and ignores anything your CSS sets on html. So @media (min-width: 40em) means 640px. If the user raises their default to 20px it becomes 800px, and that is the behavior you want: a layout that switches to its narrow form when the text gets big.

Rem behaves identically to em in media queries for the same reason. Px breakpoints are the ones that don't follow the user's setting.

Px to em converter for font sizes in older stylesheets

Before rem had full browser support, em was the only relative unit. Many stylesheets from that time set everything in em and fought the compounding with resets such as li li { font-size: 1em }.

If you maintain one of these, the nested mode of this px to em converter (online, with nothing to install) tells you what a deeply nested element really renders at. Type the em value, count the levels between the element and the nearest ancestor with a pixel size, and read the result.

Converting those font sizes to rem removes the compounding without changing how the page looks. Convert from the computed pixel size shown in your browser's developer tools, though, and not from the em value in the file.

This page is about text. For the physical size of an image, the pixels to inches and pixels to cm converters cover those units.

Questions and answers

What is 1em in px?

1em equals the size of the parent element's text. That is 16px in a default browser with no font-size rules, 20px inside an element whose parent is 20px, and so on. For properties other than font-size, 1em is the element's own text size.

How do I convert px to em in CSS?

Divide the pixel size you want by the parent's computed font size. With a 16px parent, 18px works out to 18 ÷ 16 = 1.125em. If you aren't sure what the parent resolves to, the Computed panel in the browser's developer tools shows its font-size in pixels.

How do I stop nested text getting bigger?

A rule like font-size: 1.2em on an element inside another element with the same rule gives 1.2 × 1.2 = 1.44 times the base, and three levels give 1.728 times. Switch the rule to rem, or add a rule that resets nested elements to 1em.

Should padding be in em or rem?

Padding inside a component (buttons, badges, inputs) is often best in em, so it scales with that component. Spacing between components and page margins is usually better in rem, so the whole layout uses one consistent scale.

What does 0.75em mean?

0.75em is three quarters of the parent's size: 12px inside a 16px parent, 15px inside a 20px parent. Written as a percentage it is 75%.

All image, photo and design calculators