PX to REM Converter

Convert px to rem and rem to px, with a ready-made table for common sizes. Change the root size if your project doesn’t use the browser default of 16px.

CSS1.5rem

Formula: rem = px ÷ root font size. EM works the same way but is relative to the parent element’s font size.

PixelsREM

PX vs REM vs EM: Which CSS Unit to Use for Font Sizes, Spacing and Media Queries

CSS offers several length units, and three come up constantly in everyday styling: px, rem and em. They can all produce the same size on screen, but they behave very differently when users change their browser settings or when elements are nested. Choosing the right one makes layouts more accessible and easier to maintain.

CSS units px, rem and em compared with font sizes at a 16 pixel root size

The three units

px (pixels) is an absolute CSS unit. One CSS pixel is defined as 1/96 of an inch at a typical viewing distance; on high-density screens, one CSS pixel covers several physical pixels.

rem (root em) is relative to the font size of the root element (html). By default, browsers set that to 16px, so 1rem = 16px, 1.5rem = 24px.

em is relative to the font size of the current element (or, for the font-size property itself, the parent’s font size). It compounds when nested.

UnitRelative toChanges with user’s default font size?Compounds when nested?
pxNothing (absolute)NoNo
remRoot font sizeYesNo
emCurrent/parent font sizeYesYes

Why rem matters for accessibility

Browsers let users set a default font size (in Chrome: Settings → Appearance → Font size). People with low vision often increase it from the default “Medium” (16px) to 20px or more. If your font sizes are in rem, they scale with that setting. If they’re in px, they ignore it.

This is different from zoom, which scales everything, including px values. Zoom works with any unit. The default font size setting only affects relative units. Respecting both is part of good accessibility practice, and WCAG 1.4.4 requires that text can be resized to 200% without loss of content or function.

The em compounding problem

Because em is relative to the parent, nested elements multiply:

.list { font-size: 1.2em; }

A list inside a list is 1.2 × 1.2 = 1.44 times the base size; three levels deep, 1.73 times. That’s rarely intended, and it’s why rem became the default for font sizes.

When em is the right choice

em’s relativity is useful when something should scale with the element’s own text:

  • Padding on buttons: padding: 0.5em 1em means a larger button text automatically gets proportionally larger padding.
  • Icon sizes next to text: width: 1em; height: 1em makes an icon match the text it sits beside.
  • Letter spacing: letter-spacing: 0.05em scales with font size.
  • Media queries: browsers evaluate em and rem in media queries against the initial font size, and em/rem breakpoints respond consistently when users change their default font size.

Practical rules

What you’re stylingRecommended unitWhy
Font sizesremRespects user settings, no compounding
Spacing (margins, padding, gaps)rem (or px on a strict 8pt grid)Keeps proportion with text
Component-internal paddingemScales with the component’s text size
Borders and hairlinespxA 1px border should stay 1px
Box shadowspxVisual effects don’t need to scale
Media query breakpointsem or remResponds to font size settings
Line heightUnitless (1.5)Scales with each element’s font size
Max-width for textch or remTies line length to text size

The 62.5% trick and why to avoid it

A popular old technique sets html { font-size: 62.5%; } so that 1rem equals 10px, making conversions easy (1.6rem = 16px). It has downsides:

  • Every component must set its own font size, or text renders at 10px by default.
  • Third-party components that assume 1rem = 16px end up too small.
  • It confuses anyone joining the project.

Converting px to rem is just division by 16. A px to rem converter or a CSS preprocessor function handles it, so the trick isn’t necessary.

Converting px to rem

rem = px ÷ root font size

pxrem (base 16)
120.75
140.875
161
181.125
201.25
241.5
322
483

Designers usually work in px in Figma; developers convert to rem when implementing. Keeping the design scale on round numbers (multiples of 4 or 8) gives clean rem values.

Other units worth knowing

  • % is relative to the parent (for widths) or the parent’s font size (for font-size).
  • vw / vh are relative to the viewport; use them inside clamp() for fluid sizes, never alone for text. See our viewport units guide.
  • ch is the width of the “0” character; max-width: 65ch is a quick way to limit line length.
  • pt (points) belongs to print. 12pt = 16px at the CSS standard of 96 pixels per inch; our design units guide covers print units.