Skip to content
Finance & Money

REM vs PX CSS

A rem is a CSS length equal to the font size of the root element (the html element). Browsers set that to 16px by default, so out of the box:

3 min read

A rem is a CSS length equal to the font size of the root element (the html element). Browsers set that to 16px by default, so out of the box:

  • px = rem × 16, so 1.5rem = 24px
  • rem = px ÷ 16, so 20px = 1.25rem

The phrase "by default" is what separates the two units. Pixels stay fixed. Rem values grow or shrink when the root font size changes, including when a reader increases the default font size in their browser settings.

Quick conversion table (16px root)

pxrem
12px0.75rem
14px0.875rem
16px1rem
20px1.25rem
24px1.5rem
32px2rem

If your project sets a different root size, divide or multiply by that instead. With html { font-size: 20px; }, 1.5rem is 1.5 × 20 = 30px. That is why a converter needs to know the base before it can give a correct answer.

Why the difference matters: user font settings

Many people raise the default font size in their browser because small text is hard for them to read. When a site sizes its text in rem and leaves the root size alone, that setting is respected. A reader who chooses 20px as the default sees 1rem text at 20px and 1.5rem headings at 30px.

If the same text is set in px, the font-size preference has no effect on it. The reader can still zoom the whole page, but the preference they chose for reading is ignored. This is the main practical reason accessibility guidance favors relative units for text.

A related pitfall: setting html { font-size: 62.5%; } so that 1rem equals 10px makes the arithmetic easier. It still scales with user settings, because it is a percentage of the user's default, but it shrinks everything that is not explicitly resized. Many teams now simply work with 16px as the base.

rem vs. em

An em is relative to the font size of the element itself, which it usually inherits from its parent. That makes em compound. A 1.2em list inside a 1.2em list ends up 1.44 times the base. A rem always refers to the root, so it does not compound. Use em when something should scale with its local text, such as padding on a button that should grow with the button's label. Use rem for consistent sizing across the page.

A practical rule for choosing

UseUsuallyWhy
Font sizesremRespects the reader's font-size preference
Spacing around text (margins, padding)rem or emKeeps layout proportional when text grows
Media query breakpointsem or remBreakpoints respond to text size, not only screen width
Borders, hairlines, shadowspxA 1px border should stay crisp and thin
Images and icons with fixed artworkpx (or relative, if they sit inline with text)Depends on whether they should scale with text

These are common conventions, not hard rules. The goal is that when someone enlarges the text, the layout grows with it and nothing overlaps or gets cut off.

Converting with the calculators

The REM to PX Converter multiplies by the base font size, which is 16px unless you change it. Enter 1.5 and it returns 24px, or 30px with a base of 20. The PX to REM Converter goes the other way: 14px becomes 0.875rem at a 16px base. Set the base to match your project's root font size so the results line up with what the browser renders.

Converting CSS units follows the same logic as any other unit conversion, a fixed factor applied once. See the conversion-factor method for the general approach.

Try the calculators from this article