Pixels to Em
1 Pixel (px) = 0.0625Em (em)
By KAMP Inc. / UnitOwl · Last reviewed:
How to Convert Pixels to Em?
To convert pixels to em units, divide the pixel value by the parent element's font size (typically 16px for the root). One em is equal to the computed font size of the element. Assuming a 16px base font size (the browser default), 1em = 16px, so 24px = 1.5em and 32px = 2em. The em unit is fundamental to responsive web design because it scales proportionally with text size. Unlike fixed pixel values, em-based sizing adapts when users change their browser font size, making content more accessible. Designers and developers use this conversion daily when translating pixel-perfect mockups into flexible, accessible CSS. Understanding the px-to-em relationship is critical for building layouts that respect user preferences and work across different devices and accessibility settings. It is most useful for component-level sizing, where padding, icons, or nested elements should grow in proportion to the local text size instead of staying fixed. That makes px-to-em conversion a common step when modernizing an older pixel-based stylesheet or turning a static design handoff into a more resilient UI.
How to Convert Pixel to Em
- Determine the base font size (usually 16px for the root element).
- Divide the pixel value by the base font size to get em.
- The formula is: em = px / base-font-size.
- With the default 16px base: 1em = 16px, 0.5em = 8px, 2em = 32px.
- Important: em is relative to the parent element. If the parent has a different font size, use that instead of 16px.
Real-World Examples
Quick Reference
| Pixel (px) | Em (em) |
|---|---|
| 1 | 0.0625 |
| 2 | 0.125 |
| 3 | 0.1875 |
| 5 | 0.3125 |
| 10 | 0.625 |
| 15 | 0.9375 |
| 20 | 1.25 |
| 25 | 1.5625 |
| 50 | 3.125 |
| 75 | 4.6875 |
| 100 | 6.25 |
| 250 | 15.625 |
| 500 | 31.25 |
| 1,000 | 62.5 |
History of Pixel and Em
The "em" unit takes its name from traditional typography, where it originally referred to the width of the capital letter "M" in a given typeface. In modern CSS, it was redefined to equal the computed font size of the current element. The W3C adopted em as a CSS unit to enable relative sizing that adapts to user preferences. When CSS was first specified in 1996, em was already considered a best practice for accessible text sizing. The push for em and rem units accelerated with the rise of responsive web design in the 2010s, as fixed pixel sizing did not adapt well to the enormous range of screen sizes from watches to televisions.
Common Mistakes to Avoid
- Forgetting that em compounds. If a parent is 1.5em and a child is also 1.5em, the child's computed size is 1.5 x 1.5 = 2.25 times the root font size. This compounding effect can cause unexpected sizing in deeply nested elements. Use rem instead of em to avoid this.
- Always dividing by 16 regardless of context. Em is relative to the parent element's font size. If the parent is 20px, then 1em = 20px in that context, and converting 30px requires dividing by 20, not 16.
- Using em for everything without considering rem. For font sizes and component-level spacing, rem (relative to root) is often more predictable than em (relative to parent). Use em intentionally when you want proportional scaling relative to the nearest text size.
- Converting component spacing from px to em using the page body size instead of the component's local font size. If a card uses 18px text, a 24px padding target is 1.333em in that card, not 1.5em.
Frequently Asked Questions
What is the difference between em and rem?
Why not just use pixels everywhere?
When should I use em vs. rem vs. px?
Is 16px always the default base font size?
How many em is 24px at an 18px parent size?
Note: Em and rem assume a 16px base font size by default. If your project sets a different root font size (e.g., html { font-size: 62.5%; } for a 10px base), adjust all px-to-em calculations accordingly. The "62.5% trick" makes mental math easier: 1rem = 10px, 1.6rem = 16px, 2.4rem = 24px.
Sources & References
- NIST β Units and Conversion Factors β Official unit conversion factors from the National Institute of Standards and Technology.
- BIPM β The International System of Units (SI) β International SI unit definitions from the International Bureau of Weights and Measures.