Skip to the content

PX to REM Converter

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

px

Browsers start at 16 px.

px
rem
em
1.5em
inside an element whose font size is 16 px
Points
18pt
1 px is 0.75 pt
Percent
150%
of the base font size

Convert a whole stylesheet

 

Common sizes at a base of 16 px

PixelsremPointsPercent
8px0.5rem6pt50%
10px0.625rem7.5pt62.5%
12px0.75rem9pt75%
14px0.875rem10.5pt87.5%
16px1rem12pt100%
18px1.125rem13.5pt112.5%
20px1.25rem15pt125%
24px1.5rem18pt150%
32px2rem24pt200%
48px3rem36pt300%
64px4rem48pt400%
Share this tool:TwitterFacebookLinkedInWhatsAppEmail

The sum

A rem is the font size of the root element, <html>. Divide pixels by that size to get rem, multiply rem by it to get pixels. Every major browser starts with a root size of 16px, so 24px is 24 ÷ 16 = 1.5rem, and 0.875rem is 0.875 × 16 = 14px.

UnitMeasured against24px at a base of 16
remThe font size of <html>1.5rem
emThe font size of the element itself1.5em, if that size is 16px
%In font-size: the font size of the parent150%
ptNothing. CSS fixes an inch at 96px and at 72pt18pt

rem or em

Both scale with text, but against different things. A rem means the same everywhere on the page. An em follows the element it is used on, which is useful for padding that should grow with a button's own text, and treacherous for font sizes: inside font-size an em refers to the parent, so the effect multiplies. A list at 0.9em inside another list at 0.9em ends up at 0.81 of the surrounding text.

That is also why the stylesheet converter only handles rem. What an em comes to in pixels depends on where the rule is used, and the CSS alone does not say.

What rem buys you

Browsers let people choose a larger or smaller default font size in their settings. That setting changes the 16px the root starts from. Sizes in rem, em and percent follow it; sizes in px do not. Page zoom is a different thing: it enlarges everything, pixels included, so it tells you nothing about whether a layout respects the font-size setting.

Font sizes, line heights and the spacing around text gain the most from rem. A 1px border is usually meant to stay a hairline however large the text gets, which is why the converter can leave 1px alone.

The 62.5% trick

html { font-size: 62.5%; }
body { font-size: 1.6rem; }

62.5% of 16px is 10px, so 1rem becomes 10px and the sums can be done in your head: 24px is 2.4rem. Because it is a percentage, the reader's own setting still comes through.

It is debatable all the same. Everything written for a 16px root, such as a component library or a framework's spacing scale, comes out at 62.5% of its intended size. The body needs its own font size or all text is 10px. And the only thing gained is easier arithmetic, which a converter does anyway. If you use it, set the base above to 10.

Media queries are different

Inside @media, rem and em ignore whatever your stylesheet sets on <html>. They are measured against the browser's own default: 16px, or what the reader chose. With the 62.5% trick width: 48rem is 480px, but @media (min-width: 48rem) still switches at 768px.

The converter follows that rule. It leaves media queries untouched unless you ask for them, and then converts them against 16px, whatever the base is.

What the stylesheet converter skips

Comments, quoted strings and url(…) are copied as they are, and so are names that merely contain a size, such as .gap-4px. Zero is left alone because it is the same in every unit. Results are rounded to four decimals, which is exact for every whole pixel at a base of 16.

See all 8