Px to em converter

Enter a pixel value and the font size of the parent element to get the em value, or convert em back to px. 24px inside a 16px parent is 1.5em; the same 1.5em inside a 20px parent is 30px, and three nested 1.2em levels turn 16px into 27.65px.

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 · Updated 27 October 2026

How to use the px to em converter

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

That third box is what makes this a different tool from a rem converter. Rem always divides by the root (<html>) size; em divides by the parent, so the same pixel value gives different em values in different places on the page. If you want the root-relative unit instead, 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". 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). So:

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

Examples: 24px inside a 16px parent is 24 ÷ 16 = 1.5em. 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. Because 1em is exactly the parent size, em and percentages are interchangeable for font-size: 0.875em is the same as 87.5%.

For every property other than font-size (padding, margin, width, letter-spacing, border-radius), em refers to the element's own computed font size. A button with font-size: 1.25em; padding: 0.5em 1em inside a 16px parent has a 20px font and 10px by 20px padding, because the padding is measured against the button's own 20px, not the parent's 16px.

Em compounding: why nested em values multiply

Here is the behaviour that catches people out. If a stylesheet says li { font-size: 1.2em } and a list is nested inside another list, the inner items are 1.2em of the outer items, which were already 1.2em of their 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, 73% bigger than the body, even though every rule only asked for "a bit larger". The same thing happens in reverse with values below 1: small { font-size: 0.8em } nested twice gives 16 × 0.8² = 10.24px, which is below the size most people can read comfortably. The nested em mode above shows each level so you can see where a size went wrong, and the "same value in rem" row shows what you would have got with rem, which 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%

The numbers are identical to a px to rem table when the parent happens to be 16px, which is exactly why the two units are so often confused. Change the parent box to 20px or 14px and every row moves; a rem table would not.

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, with a single rule.
  • Em for icons sized to the text they sit beside: 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 that should scale with the glyphs.
  • Rem for font-size on almost everything, so that nested components don't drift in size.

Mixing them up is the usual cause of "why is this text huge inside the sidebar" bugs. If you are reading an existing stylesheet and see 0.75rem, that is 12px at the default root regardless of nesting (0.75 rem in px is always 0.75 × root); if you see 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, and if the user raises their default to 20px it becomes 800px, which is the behaviour you want: a layout that switches to its narrow form when the text gets big. For the same reason, em and rem behave identically in media queries, and 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, and many stylesheets from that era set everything in em and fought the compounding with resets such as li li { font-size: 1em }. If you are maintaining one, the nested mode of this px to em converter (online, nothing to install) is a quick way to work out what a deeply nested element actually 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 their appearance, as long as you convert from the computed pixel size shown in your browser's developer tools rather than from the em value in the file. For sizing images rather than text, the pixels to inches and pixels to cm converters cover physical units.

Questions and answers

What is 1em in px?

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

Is em the same as rem?

No. Rem is relative to the root `<html>` size and never changes within a page; em is relative to the parent (for font-size) or the element itself (for everything else), so it changes with nesting. They give the same number only when the parent happens to equal the root size.

How do I convert px to em in CSS?

Divide the pixel size you want by the parent's computed font size: 18px inside a 16px parent is 18 ÷ 16 = 1.125em. In the browser's developer tools, the Computed panel shows the parent's font-size in pixels if you aren't sure what it resolves to.

Why does my nested text keep getting bigger?

Because em font sizes compound. A rule like `font-size: 1.2em` applied to an element inside another element with the same rule gives 1.2 × 1.2 = 1.44 times the base, and three levels gives 1.728 times. Either switch it 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%. The matching rem value, 0.75rem, is always 12px at the default root.

All image, photo and design calculators