CSS Length Unit Converter

Convert between px, rem, em, pt, in, cm, mm, vw and vh. Essential for responsive design and pixel-perfect CSS.

Value
From
To

The absolute units

These have a fixed physical size and do not respond to user settings:

UnitRatioNotes
px1/96 inchThe base unit; technically a CSS pixel, not a device pixel
pt1/72 inchThe typographic point, from print
pc12 pt = 1/6 inchThe pica, used in typography
in96 pxPhysical inches
cm96/2.54 pxPhysical centimetres
mm96/25.4 pxPhysical millimetres

The relative units

These depend on context, which is what makes them good for accessibility:

UnitRelative toBest for
remRoot font size (usually 16px)Almost everything — respects user font settings
emParent font sizePadding and margins that should scale with text
%Parent dimensionFluid layouts
vw / vh1% of viewport width/heightFull-screen sections
chWidth of the 0 characterText inputs sized to their content

Why rem beats px for font sizes

When a user increases their browser's default font size to read more comfortably, px sizes ignore that preference while rem scales with it. This is an accessibility requirement, not a stylistic choice. The recommended pattern is to set html { font-size: 62.5% } so that 1rem equals 10px in the source, then write all other sizes in rem.

When px is still correct

Use px for borders, hairline separators, and anything that should not scale — including box-shadow offsets. For media queries, use em rather than px so they respond to the user's font size.

Frequently asked questions

Is 1rem always 16px?

No. It equals the root font size, which is 16px by default but changes if the user adjusts their browser font size, or if the page sets html { font-size: 62.5% }.

Should I use rem or em for font sizes?

rem. It scales with the user's root font size preference, which is an accessibility requirement. em is better for padding and margins that should scale with the text.

When is px still correct?

For borders, hairline separators and shadow offsets — anything that should not scale. For media queries, use em so they respond to the user's font size.

How are vw and vh calculated?

1vw is 1% of the viewport width and 1vh is 1% of the viewport height. The converter assumes a 1920x1080 viewport.

Why did my vw conversion look wrong?

The result depends on the actual viewport, not a fixed number. This tool uses 1920x1080 as the reference, so treat vw and vh as approximations.