css unit converterpx to remcss unitsrem em

Convert px to rem, em, vw and vh in CSS: Which to Use

Convert px, rem, em, vw, vh and pt with configurable base font-size and viewport, and learn which reference value each unit uses and when to pick it.

August 22, 2026·4 min read

To convert px to rem, divide by the root font size. With the 16px base, which according to MDN is the most common browser default, 24px is 1.5rem. If your project uses a different base, the result changes.

A design arrives in pixels, but your project uses rem to respect the user's accessibility settings. What's missing for the conversion is that base, and it isn't always the default one.

Why the conversion depends on context

Most CSS unit conversions depend on a variable reference value:

  • px to rem: depends on the root element's (html) font-size. MDN notes the default is usually 16px, but user preferences can change it.
  • px to em: depends on the reference font-size. According to MDN, when em is used in the font-size property it takes the parent's inherited size; in any other property it takes the element's own computed size.
  • vw and vh: depend on the viewport's size, so their pixel value changes with the screen.

There's no fixed conversion table: the result depends on your project's context.

How to convert CSS units correctly

  1. Enter the value in any of the nine fields. The others update instantly.
  2. Set the base font-size in the settings panel. That value is used for both rem and em, and it defaults to 16px.
  3. Set the viewport if you need vw or vh. The tool uses the width and height you enter (1440 × 900 by default), and the real size of your window doesn't affect the result.
  4. Copy the value with its unit.

Be careful with em: the converter always calculates it from the base you configure. In a nested element, you'll need to work out the parent's size yourself.

You can do it for free with the CSS unit converter on this site.

When to use each unit

  • px: a fixed value. It doesn't follow the root font size, so it doesn't change if the user changes their browser's default text size.
  • rem: relative to the root font size. It's the natural choice for typography and spacing that should scale with the user's global settings.
  • em: relative to the font size of its own element or its parent. It works when a value should follow a specific piece of text, but if it's nested several levels deep, the changes add up.
  • vw and vh: relative to the browser window's size. They let an element take up a share of the screen.
  • pt, cm, mm and pc: absolute units defined from the inch. According to the CSS specification, 1pt is 1/72 of an inch, which is 1.333px, and 1pc is 16px.

Why rem scales with the user's preferences

A user who increases their browser's default font size, for example because of low vision, expects the text on the web to grow. A rem measurement is calculated from the root font size, which can change with that preference, so it follows the user's setting. A px measurement doesn't depend on that value and doesn't follow it. To see what accessibility requires for text, read web accessibility in practice.

Frequently asked questions

Why doesn't 16px always equal the same value in rem? Because 1rem equals the root element's font-size in your project. If you change it, 16px becomes a different number of rem: with a 20px base, 16px is 0.8rem.

When should I use em instead of rem? When you want a value to follow the font size of its own element or its parent, such as the margin of a heading, rather than the global size of the page.

Do vw and vh change if the user resizes the window? Yes. They are relative to the viewport's size at each moment. The converter, however, uses the viewport you enter in the settings.

Is anything I convert saved? No. The calculation happens in your browser, and the tool doesn't send or store the values.


Convert between px, rem, em, vw, vh, pt, cm, mm and pc in real time, for free, with the CSS unit converter, with configurable base font-size and viewport.

Try it without code

CSS Unit Converter

px, rem, em, vw, vh, pt in real time.

Open CSS Unit Converter

Built by

Miguel Ángel Colorado Marin (MACM)

Full-Stack Developer · Guadalajara, España

I develop web apps, digital tools and full projects — from design to deployment.

Contact me