A decade of Canvas at your command — powered by our custom cutting-edge, continuously trained AI engineStart Building →

CSS Tool

px to rem Converter

Convert pixel values to rem (and back) with a customisable root font size. Includes bulk conversion mode and one-click CSS custom properties export — perfect for Bootstrap 5 and Canvas HTML Template workflows.

px

Enter any px value

= 16px at root 16px

Bulk Converter

Paste multiple px values separated by commas or new lines.

What is rem in CSS?

rem stands for “root em” — it is a relative unit based on the font size of the root <html> element. By default all browsers set this to 16px, so 1rem = 16px, 1.5rem = 24px, and so on.

The key advantage of rem over px is accessibility. When a user increases their browser’s default font size, everything measured in rem scales up proportionally. Pixel values are absolute — they ignore user preferences entirely. This is why Bootstrap 5 uses rem for nearly all typography, spacing and component sizes.

In the Canvas HTML Template, font sizes, section padding, and spacing utilities are all rem-based. When you customise Canvas with a <style> block or CSS variable overrides, using rem keeps your design consistent and accessible. This converter makes the arithmetic instant.

em behaves the same way as rem when your base size is consistent, but compounds with nested elements — a 1.2em font inside a 1.2em container becomes 1.44em of the root size. For layout and spacing, rem is almost always the safer choice.

How to use this tool

  1. 1

    Set your root font size (default 16px). Change this if your project sets html { font-size: 18px } or similar.

  2. 2

    Enter a px value in the left field — the rem result appears instantly on the right.

  3. 3

    Or enter a rem value on the right to see the equivalent px size.

  4. 4

    For multiple values, use the Bulk Converter — paste a comma or newline-separated list of px values.

  5. 5

    Click 'Copy all as CSS custom properties' to export your conversions as :root { --size-24: 1.5rem; } ready to paste into your stylesheet.

Common conversions at 16px root

These are the most frequently used values in Bootstrap 5 and Canvas Template projects.

pxremCommon use
12px0.75remSmall labels, captions
14px0.875remSecondary text, badges
16px1remBase body text
18px1.125remLead paragraphs
20px1.25remH5 / subheadings
24px1.5remH4 / section subheadings
32px2remH3 / major headings
48px3remH2 / section titles
64px4remH1 / hero headings
80px5remDisplay / XL hero text

Frequently Asked Questions

What is the difference between rem and em in CSS?

rem (root em) is always relative to the font-size of the root <html> element. em is relative to the font-size of the nearest parent element that has a font-size set. This makes rem more predictable for layouts and spacing because it doesn't compound with nested elements the way em can.

What is the default root font size in browsers?

All modern browsers default to 16px for the root font size. This means 1rem = 16px unless the user or stylesheet changes the html element's font-size. Some older CSS patterns set html { font-size: 62.5% } to make 1rem = 10px, but this is no longer recommended as it overrides user accessibility preferences.

Why does Bootstrap 5 use rem instead of px?

Bootstrap 5 uses rem for font sizes, spacing utilities, and component sizing because rem respects the user's browser font-size preference. If a user sets their browser to a larger font size for accessibility, rem-based layouts scale correctly. Pixel values are absolute and ignore this setting, which can break accessibility for low-vision users.

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. For a custom root size of 18px: 24px ÷ 18 = 1.333rem. This tool handles all the arithmetic for you — just enter the px value and the result updates instantly.

Should I use rem or px for borders?

Use px for borders, outlines, and hairlines. A 1px border should stay exactly 1px regardless of font size changes — scaling it with rem makes no sense visually. Use rem (or em) for font sizes, padding, margin, line-height, and gap, so they scale proportionally when users change their browser font-size preference.

Ready to build a full HTML layout?

Canvas Builder generates production-ready Canvas HTML Template pages in seconds — rem values, spacing and typography included.

Try Canvas Builder