Converters
By ToolzBank Team•
3 min read
•Monday, October 19, 2026•Updated Monday, October 19, 2026

PX vs REM in CSS: How to Convert Pixels to REM

What rem means, why rem-based sizes are better for accessibility, the simple px-to-rem formula, and how to convert a whole stylesheet at once.

#px to rem#rem to px#css units#responsive css

Pixels are the most intuitive CSS unit, but they ignore one important thing: the font size a visitor sets in their browser. Sizes in rem scale with that setting, which makes text more readable for people who need larger type and lets you scale a whole design by changing one value.

What rem means

1rem equals the font size of the root html element. Every major browser uses 16px by default, so with no custom setting 1rem = 16px, 1.5rem = 24px and 0.875rem = 14px. If a visitor raises their default font size to 20px, 1rem becomes 20px and everything sized in rem grows with it.

The formula

rem = px ÷ root font size. With a 16px root: 24px ÷ 16 = 1.5rem; 14px ÷ 16 = 0.875rem; 40px ÷ 16 = 2.5rem. To go back: px = rem × root font size.

rem vs em

em is relative to the font size of the current element, so nested elements multiply — 1.2em inside 1.2em is 1.44 times the parent's parent. rem always refers to the root, so it stays predictable. Many teams use rem for font sizes and spacing, and em for things that should scale with their own text, such as padding inside a button.

How to convert px to rem

  1. Open the PX to REM Converter.
  2. Keep the root size at 16px, or enter the root size your site uses.
  3. Type pixels to get rem, or rem to get pixels — both boxes stay in sync — or click a value in the reference table.
  4. To convert a stylesheet, paste the CSS into the bulk box: every px value becomes rem, optionally keeping 1px hairline borders in pixels.

Should you avoid the 62.5% trick?

Setting html { font-size: 62.5%; } makes 1rem = 10px for easy maths, but you then have to set a larger font size on the body, and some third-party components assume 16px. Converting with the real root size is usually simpler.

Frequently Asked Questions

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16px root, 24px ÷ 16 = 1.5rem.

What is 1rem in pixels?

1rem equals the root html font size, which is 16px by default in all major browsers.

Is rem better than px for accessibility?

Yes for text. rem sizes grow when a visitor increases the browser’s default font size, while px sizes stay fixed.

Should borders use rem too?

Usually not. 1px hairline borders are typically kept in pixels so they stay crisp; the converter can keep them as px.