Skip to content
CSS length units

CSS Units Converter

Convert between px, rem, em, %, vw, vh, vmin, vmax, pt, pc, in, cm, mm, Q, ch and ex using a reference context you control — root font size, parent font size, viewport, and the font metrics behind ch and ex.

Reference context

px
px
px
px
Why a context? rem, em, %, viewport, ch and ex have no fixed size — they resolve against the font or viewport. Set them here for exact answers.

Single value

= 16 px

1 rem = 16px · 1 em = 16px · 1 vw = 12.8px · 1 vmin = 8px · 1 ch = 8px

16px in every unit

Same length, expressed in all sixteen units. The % row is measured against the viewport width; the em, ch and ex rows against 16px.

UnitValue1 unit =Resolved against
px16px1pxCSS pixel (1/96 in, device-independent)
rem1rem16pxroot font size
em1em16pxthis element's / parent font size
%1.25%12.8pxpercentage — see the % basis setting
vw1.25vw12.8px1% of viewport width
vh2vh8px1% of viewport height
vmin2vmin8px1% of the smaller viewport side
vmax1.25vmax12.8px1% of the larger viewport side
pt12pt1.333333pxpoint — 72 per inch
pc1pc16pxpica — 12 points, 6 per inch
in0.166667in96pxinch — 96px
cm0.423333cm37.795pxcentimetre — 2.54 per inch
mm4.233333mm3.779528pxmillimetre
Q16.933q0.944882pxquarter-millimetre
ch2ch8pxwidth of the "0" glyph
ex2ex8pxx-height of the font

Fluid clamp() builder

Pick a size at a small viewport and a size at a large viewport; the builder solves the linear interpolation and hands you a clamp() that hits both exactly.

px
px
px
px
clamp(1rem, 0.86957vw + 0.80435rem, 1.5rem)
at 360px viewport → 16px
at 820px viewport → 20px
at 1280px viewport → 24px

Which unit for what

Use rem for type and spacing

rem tracks the user's browser font-size preference, so it scales for accessibility. Your current value is 1rem.

Use px for hairlines and fixed chrome

Borders, icon strokes, 1px outlines and shadow offsets should not scale with text. 16px is a hard pixel.

Use em for component-local scaling

em is relative to the element's own font-size, so a button's padding in em grows with its label. Nesting compounds, so keep it shallow.

Use % carefully

Percentages mean different things per property: width/height → the containing block, font-size → the parent font size, line-height → the element's own font size.

Use vw/vh/vmin/vmax for viewport-bound layout

Headline scaling, hero heights, full-bleed sections. 100vh overflows on mobile because of dynamic toolbars — prefer 100dvh. 1.25vw is the current 1vw step.

Use ch for measure (line length)

max-width: 65ch is the classic readable column. Also handy for aligning monospace output. 1ch here is 2ch.

Use ex and Q rarely

ex follows the x-height and varies a lot between fonts; Q (quarter-millimetre) only really belongs in print stylesheets.

Use clamp() instead of media queries for fluid type

One declaration replaces a stack of breakpoints. Always keep the middle expression unit-consistent with the min and max.

About this tool

This converter resolves every common CSS length unit to CSS pixels through the reference context you configure — root and parent font sizes, viewport size, and the font metrics behind ch and ex — then expresses the same length in all sixteen units at once. It also solves fluid clamp() expressions from two viewport anchors. Everything is computed in your browser with plain arithmetic; nothing is uploaded and it works offline. Absolute units (pt, pc, in, cm, mm, Q) assume the CSS reference pixel of 1/96 inch.

  • 100% free — no account needed
  • Runs in your browser
  • Nothing is uploaded

Frequently asked questions

Is CSS Units Converter really free?

Yes. CSS Units Converter is completely free on PureBrowser — every feature, with no account, no trial, and no credit card.

Does CSS Units Converter upload my data?

No. CSS Units Converter runs entirely inside your browser, so anything you type, paste, or open stays on your own device.

Do I need to sign up or install anything?

Neither. There is no account and nothing to download — open the page and CSS Units Converter is ready to use on desktop or mobile.

Does CSS Units Converter work offline?

Once the page has loaded, yes. All of the processing happens locally in your browser, so it keeps working without a connection.