Type a value in px, rem or em and the other units update instantly. Change the root font size if your site doesn't use 16px, grab values from the 1-100px table, or paste a whole stylesheet to convert every px value at once.
px
=
=
px
PX to REM table (base 16px)
Click a cell to copy its rem value.
Convert CSS
Advertisement
Advertisement
How to use the PX to REM Converter
Set the root font size. Browsers use 16px by default. If your CSS sets html { font-size: 62.5% }, use 10.
Type a value in the PX, REM or EM box. The other two boxes update immediately.
Need em? Set the parent element's font size; em is relative to the parent, rem to the root.
Use the table for quick lookups. Click any cell to copy its rem value.
Convert a stylesheet: paste CSS into the converter below, choose the options and copy or download the converted CSS.
PX to REM formula
A rem ("root em") is a multiple of the font size of the root <html> element. Browsers set that root size to 16px unless the visitor or your CSS changes it, so:
rem = px ÷ root font size e.g. 20px ÷ 16 = 1.25rem
px = rem × root font size e.g. 2.5rem × 16 = 40px
em = px ÷ parent font size e.g. 12px inside an 18px parent = 0.6667em
If your stylesheet sets html { font-size: 62.5%; }, the root becomes 10px (62.5% of 16px) and 1rem = 10px. Set the root size above to 10 to match.
Common px to rem values (16px root)
Pixels
REM
Typical use
8px
0.5rem
Small gaps, icon spacing
12px
0.75rem
Captions, fine print
14px
0.875rem
Secondary text, buttons
16px
1rem
Body text (browser default)
18px
1.125rem
Large body text, lead paragraphs
20px
1.25rem
Small headings
24px
1.5rem
h3 headings, card padding
32px
2rem
h2 headings, section spacing
48px
3rem
h1 headings, hero spacing
64px
4rem
Display text, large layout gaps
rem vs em vs px: which should you use?
rem is the safest choice for font sizes and most spacing: every rem value on the page is based on the same root size, so it is predictable, and it grows when a visitor raises their browser's default font size. em is useful when something should scale with its own component, such as padding on a button that grows with the button's text, but nested em values multiply (1.2em inside 1.2em is 1.44 times the root). px is still fine for things that should not scale, like 1px borders, box-shadow offsets and some media query breakpoints.
The CSS converter on this page leaves comments, strings and url() paths untouched, keeps 1px values by default and, unless you untick the option, does not change the numbers inside @media queries.
Frequently asked questions
How do I convert px to rem?
Divide the pixel value by the root font size. With the default 16px root, rem = px / 16, so 24px = 24 / 16 = 1.5rem.
How do I convert rem to px?
Multiply the rem value by the root font size. With a 16px root, 1.25rem = 1.25 x 16 = 20px.
What is the difference between rem and em?
rem is relative to the font size of the root html element, so it is the same everywhere on the page. em is relative to the font size of the element's parent (or the element itself for properties other than font-size), so nested em values compound.
Why use rem instead of px?
rem values scale when a visitor changes their browser's default font size, which makes text and spacing more accessible. px values ignore that setting for font sizes.
What is 16px in rem?
16px is 1rem when the root font size is the browser default of 16px. 14px is 0.875rem, 12px is 0.75rem and 32px is 2rem.
What does html { font-size: 62.5% } do?
It sets the root font size to 62.5% of 16px, which is 10px, so 1rem = 10px and conversions become simple: 24px = 2.4rem. Set the base to 10 in this tool to match.
Should 1px borders be converted to rem?
Usually not. Hairline borders are often kept at 1px so they stay crisp at every zoom level. The CSS converter keeps 1px values by default; untick the option to convert them too.