ToolNimba

๐Ÿ“ PX to EM Converter for CSS

Shihab Mia By Shihab Mia ยท Updated 2026-07-13

Result in em
1.5 em
Same value in rem
1.5 rem

24px divided by a 16px base equals 1.5em.

Common px to em at a 16px base

Pixels em rem

To convert pixels to em, divide the pixel value by the base font size: em = px / base. With the standard 16px base a browser uses by default, 24px equals 1.5em (24 / 16), 16px equals 1em, and 8px equals 0.5em. This px to em converter does the math both ways, lets you change the base font size when your design uses a different root value, and shows the matching rem figure so you can pick the right relative unit for any CSS rule.

What is the PX to EM Converter?

An em is a relative CSS length unit. One em equals the computed font size of the element it applies to, so when you write font-size: 1.5em the browser multiplies the inherited font size by 1.5. Because the base font size in every major browser defaults to 16px, the everyday conversion most developers need is simply px divided by 16. That is why 12px is 0.75em, 20px is 1.25em, and 32px is 2em. Change the base and every result changes with it: at a 10px base, 24px becomes 2.4em rather than 1.5em.

The one detail that trips people up is what em is relative to. For most properties (padding, margin, width, gap, border-radius) an em is relative to the element's own font-size. But for the font-size property itself, an em is relative to the parent element's font-size, because the element has not computed its own size yet. This is why ems can compound: a list nested three levels deep, each set to 1.2em, ends up much larger than 1.2 times the root. rem (root em) was created to avoid exactly this compounding, since it is always relative to the root html element and never to the parent.

This tool assumes the common case where you are converting against the root font size, which is why the em and rem outputs are identical here. That matches how most teams work today: set html { font-size: 16px } (or leave the browser default), then express component sizes as em or rem multiples of 16. If a specific element has a non-default font-size and you are sizing its padding or margin in em, plug that element's own font-size into the base field to get the correct local value.

Working in relative units instead of fixed pixels makes a layout respond to user preferences. A reader who bumps their browser font size up for accessibility, or a design that scales type at different breakpoints, will see em and rem based spacing scale in proportion, while hard-coded pixels stay frozen. That is the practical reason style guides push you to convert px mockup values into em or rem before they reach production CSS.

When to use it

  • Turning pixel values from a Figma or Sketch mockup into em units for responsive CSS.
  • Converting a fixed font-size such as 18px into 1.125em so text scales with user settings.
  • Checking em to px the other way when you inherit a stylesheet written entirely in ems.
  • Sizing padding, margins, and gaps in em relative to a component with a custom font-size.
  • Comparing em and rem for the same value to decide which relative unit a rule should use.
  • Building an accessible design where spacing and type respond to the browser default of 16px.

How to use the PX to EM Converter

  1. Pick a direction: PX to EM (the default) or EM to PX.
  2. Type the value you want to convert into the first field.
  3. Set the base font size, or leave it at 16 to match the browser default.
  4. Read the em result and the matching rem value in the result cards.
  5. Click Copy to grab the value with its unit, or check the 16px reference table for common sizes.

Formula & method

em = px / base, and the reverse is px = em × base. The base is the font size the value is relative to, which is 16px by default in browsers. Example: 24 / 16 = 1.5em. When you are converting against the root font size, rem uses the same math, so 24px is both 1.5em and 1.5rem at a 16px base.

Worked examples

Convert a 24px heading margin from a mockup into em at the default base.

  1. Keep the direction on PX to EM.
  2. Enter 24 in the pixel field.
  3. Leave the base at 16 (the browser default).
  4. Divide: 24 / 16 = 1.5.

Result: 24px equals 1.5em (and 1.5rem) at a 16px base.

Convert 1.25em back into pixels to sanity check a font-size.

  1. Switch the direction to EM to PX.
  2. Enter 1.25 in the em field.
  3. Keep the base at 16.
  4. Multiply: 1.25 x 16 = 20.

Result: 1.25em equals 20px at a 16px base.

Common pixel values converted to em and rem at a 16px base

Pixelsemrem
12px0.75em0.75rem
14px0.875em0.875rem
16px1em1rem
18px1.125em1.125rem
20px1.25em1.25rem
24px1.5em1.5rem
32px2em2rem
48px3em3rem

How the same 24px value converts under different base font sizes

Base font sizeCalculationResult
10px24 / 102.4em
12px24 / 122em
16px24 / 161.5em
20px24 / 201.2em

Common mistakes to avoid

  • Assuming the base is always 16. 16px is the browser default, but a stylesheet can override html { font-size }, and any element with its own font-size changes what an em means locally. If your numbers look off, confirm the real base before converting.
  • Forgetting that em on font-size is relative to the parent. For most properties an em is relative to the element itself, but for the font-size property it is relative to the parent. Nesting elements that each set font-size in em causes the sizes to compound and grow unexpectedly.
  • Treating em and rem as interchangeable in every case. They give the same number when both are measured against the root font size, but em inherits and compounds while rem is always fixed to the root. Choose rem when you want a value that ignores nesting.
  • Rounding em values too aggressively. Cutting 0.875em down to 0.9em to look tidy shifts a 14px target to about 14.4px. Keep enough decimal places, or let the tool do the division, so the pixel intent is preserved.

Glossary

px (pixel)
An absolute CSS length unit. In CSS a px is a fixed reference size and does not scale with the parent font size.
em
A relative unit equal to the computed font size of the current element, or the parent font size when used on the font-size property itself.
rem
Root em, a relative unit always equal to the root html font size, so it never compounds through nesting.
Base font size
The font size a relative unit is measured against. The browser default is 16px unless CSS changes it.
Computed value
The final pixel value the browser resolves a relative unit to after applying all inherited and cascaded font sizes.
Root element
The html element at the top of the document, whose font size defines what 1rem equals.

Frequently asked questions

How do I convert px to em?

Divide the pixel value by the base font size: em = px / base. With the default 16px base, 24px is 1.5em, 16px is 1em, and 12px is 0.75em. Change the base if your element or root uses a different font size.

What is 16px in em?

16px equals 1em when the base font size is 16px, which is the browser default. Since 16 divided by 16 is 1, any value that matches the base is always exactly 1em.

What is 24px in em?

24px equals 1.5em at a 16px base, because 24 divided by 16 is 1.5. At a 10px base the same 24px would be 2.4em, so the base you use matters.

Is em the same as rem?

They produce the same number when both are measured against the root font size, so 24px is 1.5em and 1.5rem at a 16px root. The difference is that em is relative to the current or parent element and can compound, while rem is always relative to the root and stays fixed.

Why use em instead of px in CSS?

em is relative, so spacing and type built on it scale when a user changes their browser font size or when a design adjusts the base at different breakpoints. Fixed px values do not respond to those preferences, which can hurt accessibility.

How do I convert em back to px?

Multiply the em value by the base font size: px = em times base. For example, 1.25em at a 16px base is 1.25 x 16 = 20px. Switch this tool to EM to PX to do it automatically.