We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
A pixel and EM unit converter for front-end developers featuring custom base font sizes and real-time two-way conversion.
Overview
Understand what the tool solves, how it works, and the boundaries of its data.
An em value is relative, so there is no single fixed number of pixels in one em for every element. This converter uses a base font size in pixels: it starts at 16px, and you can change it to match the CSS context you are converting. The same px value can therefore produce different em results under different bases.
em = px ÷ base font size
px = em × base font size
With a 16px base, 24px is 24 ÷ 16 = 1.5em. With a 20px base, 24px is 1.2em. The fields convert in either direction, and the result is shown to at most four decimal places.
For font-size, em is resolved against the parent’s computed font size. For many other properties, such as padding, it is based on the element’s own computed font size. Nested em font sizes can compound as each child inherits a computed size from its parent. MDN explains these rules in its CSS font-size reference; the W3C CSS Values and Units specification defines the relative length context.
This calculator performs the arithmetic you request; it does not inspect a stylesheet or determine which element is the correct reference. Use the computed size for the specific element and property when accuracy matters.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Identify whether the value will set font-size or another property such as padding or margin. That affects which computed font size should be the base.
Use the final computed font size for the relevant parent or element after inheritance and cascading have been applied. The initial 16px is only a convenient starting assumption.
Enter pixels to obtain em, or enter em to obtain pixels. Change the base-size field if the target context differs from 16px; the opposite value updates automatically.
Copy the displayed value, apply it to the intended CSS rule, and check the resulting computed style. The converter rounds its displayed result, so small precision differences can occur.
| Pixel value | Base size | Equivalent |
|---|---|---|
| 14px | 16px | 0.875em |
| 24px | 20px | 1.2em |
| 1.25em | 18px | 22.5px |
These values follow the two formulas above. If the computed font size in the actual layout differs from the chosen base, the rendered result will differ too.
Use cases
See how the tool fits into real work and everyday tasks.
When design specs give pixel dimensions but a stylesheet uses em, convert each value using the intended element’s computed font size and verify the result after applying it.
For spacing intended to grow with a component’s typography, calculate em against that component’s font size rather than assuming a global 16px reference.
When successive em-based font sizes grow unexpectedly, calculate each step against its parent’s computed size to see how the values compound.
Q&A
Find concise answers to common questions and confusing cases.
No. Sixteen pixels is the converter’s initial base. The em value depends on the font-size context used for the CSS property.
Check the computed font size used as the base, including inheritance and nested rules. Also account for the converter’s display rounding.
Each child’s em font-size is calculated from its parent’s computed size. If each level uses a multiplier above 1, the size compounds down the tree.
Use em when a value should follow a local font-size context. Rem is based on the root element’s font size, which can make a shared root reference more predictable.
Notes
Review scope, result limitations, and important precautions before use.
Related
Discover related tools, collections, and available API capabilities.