PX to EM Converter

Convert pixels to em units or em units to pixels using any CSS base font size.

CSS pixel and em converter
Translate fixed pixel measurements and font-relative em values for responsive layouts and typography.

About pixels and em units

Pixels and ems are common CSS length units, but they represent different sizing approaches. A CSS pixel is a reference unit used by browsers to create a consistent visual measurement across devices. An em is relative to a font size in the element's context. For a property such as font-size, one em generally refers to the computed font size of the parent. For many other properties, one em refers to the computed font size of the element itself. The arithmetic is simple once the correct base is known. Divide a pixel value by the base font size to obtain em. With a 16-pixel base, 24 pixels equals 1.5 em and 8 pixels equals 0.5 em. Multiply em by the base to convert in the other direction. With a 20-pixel base, 1.25 em equals 25 pixels. The calculator supports both directions and does not assume that every design uses the browser's common 16-pixel default. Relative units can help typography and spacing respond coherently when users, themes, or components change font size. For example, padding expressed in em can grow with a button label, preserving proportions at larger text sizes. Pixels remain useful for details that should not scale in the same way, such as a fine border or a carefully controlled graphic. Neither unit is always superior; the design intent and inheritance context determine the better choice. EM should not be confused with rem. Rem is relative to the root element's font size, while em follows a local font-size context and can compound through nested elements. If a parent is 1.25 em and a child is also 1.25 em, the child's computed size can be 1.5625 times the original base. That behavior is powerful for self-contained components but can surprise developers who expect root-relative sizing. Use the actual computed base font size for an exact conversion. Browser defaults, user accessibility preferences, media queries, inherited styles, and component rules may all change it. Developer tools can show the computed value for a particular element. The calculated number is a mathematical equivalence at the selected base, not a guarantee that two declarations behave identically in every responsive or nested context. Test converted styles at different viewport sizes, zoom levels, and user font settings to confirm that the result preserves readability and layout behavior.

PX and EM conversion examples

Value and baseConverted valueUse case
24 px at 16 px base1.5 emA common heading size.
8 px at 16 px base0.5 emRelative component spacing.
1.25 em at 20 px base25 pxA larger local typography context.

How to convert PX and EM

  1. Enter the pixel or em value you want to convert.
  2. Enter the relevant computed base font size in pixels.
  3. Choose Pixels to EM or EM to Pixels.
  4. Select Convert CSS Unit and copy the resulting value into your stylesheet.

PX to EM FAQ

How do I convert pixels to em?

Divide the pixel measurement by the applicable base font size. For example, 24 pixels divided by a 16-pixel base equals 1.5 em.

What base font size should I use?

Use the computed font size that supplies the em context for the property. Sixteen pixels is a common browser default, but your stylesheet or user settings may change it.

What is the difference between em and rem?

Em is relative to a local font-size context and may compound through nesting. Rem is relative to the root element font size, which makes its reference more predictable.

Are pixels fixed physical sizes?

No, CSS pixels are reference units rather than guaranteed physical screen pixels. Device pixel ratios, zoom, and display characteristics affect how they are rendered.

Should all CSS pixels be replaced with em?

No, choose units according to the desired scaling behavior. Relative units are valuable for accessible typography, while pixels can remain appropriate for selected visual details.