Convert px to em
The em unit is relative to the font size of the parent element, which makes it useful for component-scoped sizing that scales with its context. This converter turns a pixel value into the equivalent em for a given parent font size, so you can move a design from fixed pixels to relative CSS units.
How it works
The conversion divides the pixel value by the parent element’s font size:
em = px ÷ parent font size (px)
px = em × parent font size (px)
The parent font size — not the root — is the divisor, because ems inherit and compound through nested elements. The default parent of 16px matches the browser’s usual root size.
Example
Convert 24px with a 16px parent:
- 24 ÷ 16 = 1.5em
If the parent font size were 20px instead, the same 24px would be 24 ÷ 20 = 1.2em.
| Pixels | Parent | Result |
|---|---|---|
| 24px | 16px | 1.5em |
| 12px | 16px | 0.75em |
| 24px | 20px | 1.2em |
Enter your numbers and the result updates instantly, all in your browser.