- Home
- Tools
- Color & Design
- PX to REM Converter
- PX to EM Converter
PX to EM Converter
Convert pixels to em and back for the font size the em is measured against, with the rule for which font size that is.
The parent's for font-size, the element's own for the rest.
- Percent
- 150%
- the same size, as font-size is often written
- Points
- 18pt
- 1 px is 0.75 pt
From pixels to em
Divide the pixels by a font size:
em = pixels ÷ font size
Which font size depends on the property the em is used in.
- In
font-sizean em is the font size of the parent element. Text of 24px inside a parent of 16px is 24 ÷ 16 = 1.5em. - In every other property, such as padding, margin, width or border-radius, an em is the font size of the element itself. Padding of 12px on a button with 16px text is 12 ÷ 16 = 0.75em.
The second rule is what em is good for. When the text of that button is later set to 20px, its 0.75em of padding becomes 15px by itself and the button keeps its proportions.
The usual sizes in em
| Pixels | Font size 14px | Font size 16px | Font size 24px |
|---|---|---|---|
| 8px | 0.5714em | 0.5em | 0.3333em |
| 10px | 0.7143em | 0.625em | 0.4167em |
| 12px | 0.8571em | 0.75em | 0.5em |
| 14px | 1em | 0.875em | 0.5833em |
| 16px | 1.1429em | 1em | 0.6667em |
| 18px | 1.2857em | 1.125em | 0.75em |
| 20px | 1.4286em | 1.25em | 0.8333em |
| 24px | 1.7143em | 1.5em | 1em |
| 32px | 2.2857em | 2em | 1.3333em |
| 48px | 3.4286em | 3em | 2em |
| 64px | 4.5714em | 4em | 2.6667em |
em multiplies when it is nested
Because font-size in em looks at the parent, it adds up through the page. A list at 0.875em inside another list at 0.875em is 0.875 × 0.875 = 0.766 of the text around it: 12.25px where 14px was meant. A font size in rem always refers to the root and cannot do this, which is why many stylesheets use rem for font sizes and keep em for the spacing inside a component.
Percent, and media queries
For font-size a percentage is the same thing as an em: 150% is 1.5em.
Inside a media query an em is the browser's own default font size, 16px unless the reader changed it, whatever the page's CSS sets. @media (min-width: 48em) therefore switches at 768px.
The px to rem converter page goes the other way, and explains when rem is the better unit and what the 62.5% trick costs.