PX to EM Converter
Convert pixels to em for CSS, relative to the font size of the parent element, with a table of common sizes.
| px | em |
|---|---|
Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.
How to use the PX to EM Converter
- 1 Enter the size in pixels.
- 2 Enter the font size of the parent element (16px by default).
- 3 Copy the em value.
About the PX to EM Converter
An em is relative to the font size of the element: for font-size it’s the parent’s font size, for other properties (padding, margin, width) it’s the element’s own font size. The formula is em = px ÷ font size.
With a parent font size of 16px, 24px is 1.5em. Inside an element of 20px, the same 24px is 1.2em. That makes em useful for spacing that should grow and shrink with the text, such as the padding of a button.
Because em values multiply when elements are nested (1.2em inside 1.2em is 1.44 times the outer size), many developers use rem for font sizes and em for component spacing. Values are rounded to four decimals.
Frequently asked questions
What is 1em in pixels?
The font size of the element it’s used on (or of the parent for font-size). With browser defaults that’s 16px.
Should I use em or rem?
Rem for font sizes and layout, so sizes don’t compound; em for spacing that should scale with the element’s own text, such as padding in buttons.
Why are my em sizes getting bigger and bigger?
Em values multiply when elements are nested. 1.2em inside an element that’s already 1.2em is 1.44 times the base size.
What does the parent font size mean here?
The computed font size of the element your size is relative to. Look it up in your browser’s developer tools under "Computed".