By Ahsan Khowaja (CEO) · Updated 10 November 2026
On this page
How to use the px to em converter
- Choose px to em or em to px. Choose nested em font sizes to see what happens when em values stack.
- Type the pixel or em value you have.
- Type the parent font size. This is the computed
font-sizeof 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 anh2it is whatever theh2resolves 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:
| Level | Working | Computed size |
|---|---|---|
| 1 | 1.2em × 16px | 19.2px |
| 2 | 1.2em × 19.2px | 23.04px |
| 3 | 1.2em × 23.04px | 27.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
| px | em | Percent | Notes |
|---|---|---|---|
| 8px | 0.5em | 50% | Half the parent |
| 10px | 0.625em | 62.5% | |
| 12px | 0.75em | 75% | Common caption size |
| 13px | 0.8125em | 81.25% | |
| 14px | 0.875em | 87.5% | Common secondary text size |
| 16px | 1em | 100% | Equal to the parent |
| 18px | 1.125em | 112.5% | |
| 20px | 1.25em | 125% | |
| 24px | 1.5em | 150% | |
| 28px | 1.75em | 175% | |
| 32px | 2em | 200% | Twice the parent |
| 48px | 3em | 300% |
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 1emon 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: 1emkeeps an SVG icon the same height as the letters. - Em for
letter-spacingandtext-indent, which are typographic measures and should scale with the glyphs. - Rem for
font-sizeon 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.
