Converter
Common Sizes
| Pixels | EM |
|---|
Instantly convert Pixels (px) to EM units for scalable web design.
| Pixels | EM |
|---|
In web design, EM units are scalable units that are relative to the font-size of their parent element. This makes them incredibly powerful for building modular components where sizing scales proportionally. Unlike Pixels (px) which are static, or REMs which are relative to the root HTML tag, EMs allow for localized scalability.
Designers often provide specifications in pixels, leaving developers to calculate the EM values. This calculator bridges that gap by letting you define the parent's font size and instantly converting your pixel values to EMs.
The formula to convert pixels to EM is:
EM = Target Pixels / Parent Font Size
For example, if your parent container has a font-size of 20px, and you want a child margin of 10px, the calculation is 10 / 20 = 0.5em.
REM (Root EM) is relative to the root <html> element (usually 16px). EM is relative to the font size of the element itself or its nearest parent. EM units "cascade," meaning nested EM values multiply each other, whereas REM values remain consistent throughout the document.
Use EM when you want properties like padding, margins, or child elements to scale if the component's font size changes. For example, a button where the padding grows automatically as the text size increases.
Since EM is a relative unit, 1em has no fixed value. 1em could be 16px in one part of your page and 24px in another. You must know the font size of the parent element to accurately calculate the pixel equivalent.