← back to flaviocopes.com

CSS units converter

← All tools

Enter a value in any CSS unit and see equivalents in px, rem, em, %, and pt. Set your root font size for accurate rem math.

~~~

Settings

rem uses root; em and % use parent.

Convert

Equivalents

UnitValue

Quick reference (px → rem)

Common spacing values at px root.

pxrem

rem — relative to the root font size. Use for margins, padding, font sizes you want to scale with user preferences. One rem = root px.
em — relative to the parent element's font size. Compounds when nested; fine for components sized relative to their own text.
px — absolute pixels. Use for borders, shadows, and fixed UI chrome where scaling would look wrong.

~~~

About this tool

Designers hand you specs in px; your codebase uses rem. Or you need to know what 1.25rem is at a 18px root. This converter does the math with your actual root and parent sizes, and includes a cheat sheet for common spacing values.

~~~

Read more