Skip to the content

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.

px

The parent's for font-size, the element's own for the rest.

px
em
Percent
150%
the same size, as font-size is often written
Points
18pt
1 px is 0.75 pt
Share this tool:TwitterFacebookLinkedInWhatsAppEmail

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-size an 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

PixelsFont size 14pxFont size 16pxFont size 24px
8px0.5714em0.5em0.3333em
10px0.7143em0.625em0.4167em
12px0.8571em0.75em0.5em
14px1em0.875em0.5833em
16px1.1429em1em0.6667em
18px1.2857em1.125em0.75em
20px1.4286em1.25em0.8333em
24px1.7143em1.5em1em
32px2.2857em2em1.3333em
48px3.4286em3em2em
64px4.5714em4em2.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.

See all 8