Unit Converter
PX to EM Converter
Convert a pixel length to em using the reference font size required by the CSS property you are editing.
PX to EM Converter examples
| Input | Expected result |
|---|---|
| 24 px, element font 16 px | 1.5 em for an ordinary length |
| 24 px, element font 20 px | 1.2 em for an ordinary length |
| 24 px font-size, parent font 12 px | 2 em |
| −8 px margin, element font 16 px | −0.5 em |
Supported units & limits
Supports decimal values, scientific notation, zero and signed ordinary lengths. font-size values cannot be negative. The reference font must be positive; a zero reference does not define this ratio. Enter numbers without suffixes. This is an element-style calculator, not a resolver for media queries, custom properties or CSS expressions. It does not read your stylesheet. Numeric overflow and underflow are rejected.
Common mistakes
Using the root font for em can give the wrong result on nested elements. Use rem when you intend a root-relative length. The context selector identifies which computed font size to supply; it does not discover that size for you. Nested em font sizes can compound because each level uses its inherited size. For font-size, enter the parent's computed size as the reference in the PX to EM Converter; for padding or margins, use the element's own size.
Privacy
Conversions run in your browser. This site does not upload or store the values you enter. We use Google Analytics, loaded through Google Tag Manager, to count page visits and see which tools are used; Google may set cookies for this. The hosting server may keep standard access logs when you load a page.
Conversion guide
Choose the reference before converting
Inspect the element in browser developer tools. If you are editing a margin, read that element’s computed font-size. If you are editing its font-size declaration, inspect the inherited size from its parent. Enter that reference here, then divide your desired pixel length. Check nested elements after changing an em font-size.
PX to EM Converter FAQ
Should I enter the parent or element font size?
For font-size, enter the inherited font size, normally the parent’s computed size. For ordinary lengths such as margin or padding, enter the element’s own computed font size.
Why can 1.5 em differ from 1.5 rem?
rem uses the root font size. em uses the font-size context of the property and element. They match only when those reference sizes match.
Can I convert negative pixel values?
Yes for ordinary lengths. Whether the result is usable depends on the property: margin allows negative lengths, while padding and font-size do not.