Design tools

PX to EM Converter

PX to EM Converter

Convert px to em for any parent font size, with a table and a CSS converter.

About this tool

About PX to EM Converter

Em units scale with the font size of the element they're used in, which makes them ideal for padding, icon sizes and spacing that should grow with a component's text. The catch is the maths: 1em is whatever the parent font size is, not always 16px. Set the base to that parent size (for example 14px inside a small button or 20px inside a lead paragraph) and type a value into either box to convert between pixels and em instantly. The reference table lists common pixel sizes and their em values at your base, and you can download it as CSV. Paste a block of CSS to convert every px value to em at once, keeping 1px borders, comments, strings and url() paths untouched, and leaving media query conditions alone if you prefer. Choose between 2 and 5 decimal places. If you need sizes relative to the page root instead, switch the unit to rem. Everything is calculated in your browser.

Built and maintained by Abhi JainUpdated

How to Convert PX to EM

  1. 1

    Set the base font size

    Enter the font size of the parent element in Base font size.

  2. 2

    Convert a value

    Type into Pixels or em; the other box updates. Copy the em value.

  3. 3

    Convert CSS

    Paste CSS under Convert a stylesheet and copy or download the result.

PX to EM Converter: questions and answers

How do I convert px to em?

Divide the pixel value by the parent element's font size: em = px ÷ parent font size. With a 16px parent, 24px is 1.5em; with a 20px parent, 24px is 1.2em.

What's the difference between em and rem?

Em is relative to the current element's font size, so nested ems multiply. Rem is always relative to the root font size. Use the PX to REM Converter for root-relative values.

When should I use em instead of rem?

Use em for spacing that should scale with the component's own text, such as button padding or icon size. Use rem for font sizes and layout spacing that should stay consistent across the page.

Why do my em values compound?

Because a font size in em sets the base for its children. A 1.2em list inside a 1.2em list renders at 1.44 times the outer size. Use rem for font sizes to avoid this.

More PX to REM Converter presets