Px to Em Converter

Convert pixels to em or rem for CSS, and back, against any base font size.

Convert
px
Browsers default to 16px.
Clear
In em / rem1.5emat a 16px base
Pixels24px
em / rem1.5em
Percent150%
Points (at 96 dpi)18pt

Common sizes at a 16px base

PixelsemPercent
8px0.5em50%
10px0.625em62.5%
12px0.75em75%
14px0.875em87.5%
16px1em100%
18px1.125em112.5%
20px1.25em125%
24px1.5em150%
32px2em200%
40px2.5em250%
48px3em300%
64px4em400%

The conversion

em = px ÷ base and px = em × base. With the usual 16px base, 24px is 1.5em.

em and rem are not the same

rem is always relative to the root element, so the base is one fixed number for the whole page — which is what the table above assumes. em is relative to the parent element's font size, so it compounds: an element at 1.5em inside another at 1.5em renders at 2.25 times the root size. That compounding is useful for padding that should scale with its own text, and a trap for nested type.

Why bother with relative units

A reader who sets a larger default font size in their browser gets larger text everywhere that uses em or rem, and no change at all where you hard-coded pixels. Using rem for font sizes is the single easiest accessibility win in CSS.

Media-query widths are the exception: em in a media query is always relative to the browser default, not to your root rule.