PX to EM Converter (Default 16px)

PX to EM:

Formula: (Pixel Value) / (Base Font Size) = EM value

Example: 32px / 16px = 2 EM

PX to EM Conversion Table

Pixels (px)EM

CSS Units: Pixels vs. EMs

  • Pixels (px): Pixels are absolute units in CSS. They represent a fixed size on the screen, regardless of device or screen resolution. Using pixels offers precise control over element sizes.
  • EMs (em): EMs are relative units. Their size depends on the font size of their parent element. The default font size in most browsers is 16px, so 1em is initially equal to 16px. EMs are useful for creating scalable and responsive designs.

Why Convert PX to EM?

  1. Accessibility: Users can resize text in their browsers. Designs using EMs will scale proportionally with these text size adjustments, making them more accessible to users with visual impairments.
  2. Responsiveness: EMs help create layouts that adapt smoothly to different screen sizes. Since EMs are based on font sizes, elements will resize naturally as the viewport (the visible area of a website) changes.
  3. Flexibility: Nested elements using EMs allow you to control the sizing relationships throughout a design easily. Altering the base font size predictably impacts all elements using EMs.

The Conversion Formula

To convert pixels to EMs, use the following formula:

EMs = Pixels / Target Font Size (in pixels)


If you want to convert 24px to EMs, and your base font size is 16px (standard default):

  • EMs = 24px / 16px = 1.5em

Important Note: In more complex layouts, if the parent element itself has its font-size set using EMs, calculations become more involved since nested EMs are relative to their immediate parent.

Practical Considerations

  • Base Font Size: It’s common to set a base font-size on the html or body element. All EM calculations are then based on this value.
  • Mixing Units: While EMs promote adaptability, a mix of px and EMs is often used for finer control in certain situations.
  • REM: Another relative unit, REMs, is based on the root font size (usually the html element). They can simplify calculations in complex layouts.