CSS Unit Converter

Inputs

Pick its CSS unit on the right.

The html element's font size; browsers default to 16.

For em and %.

For vw, vmin and vmax.

For vh, vmin and vmax.

Results

UnitValue
Pixels (px)—
Root em (rem)—
Em (em)—
Percent of parent font (%)—
Points (pt)—
Picas (pc)—
Inches (in)—
Centimeters (cm)—
Millimeters (mm)—
Viewport width (vw)—
Viewport height (vh)—
Smaller viewport side (vmin)—
Larger viewport side (vmax)—

CSS has absolute units (px, pt, in, cm) with fixed ratios, since 1 in is always 96 px, and relative units that depend on context: rem on the root font size, em and % on the parent’s font size, and vw, vh, vmin and vmax on the browser window. Give the context and every unit converts.

How to use it

  1. Type a length and pick its unit.
  2. Adjust the root and parent font size and the viewport if yours differ from the defaults.
  3. Read or copy the value in every other unit.

Examples: with the default 16 px root, 24px is 1.5rem and 18pt. 1in is always 96px. On a 1,440 px wide window, 10vw is 144px.

Questions and answers

Should I use px or rem for font sizes?

rem, usually: it scales when people change their browser’s default font size for readability, while px does not. Keep px for things that shouldn’t scale, like hairline borders.

What is the difference between em and rem?

rem is relative to the root (html) font size, the same everywhere on the page. em is relative to the current element’s parent font size, so it compounds when elements are nested.

Is a CSS inch a real inch?

Only on paper. On screens, CSS defines 1 in as 96 px and 1 px as a viewing angle, so physical sizes depend on the display.

Link with pre-filled values

Add # and these parameters to the end of this page's address to open the tool with values already filled in.

ParameterWhat it sets
valueThe length to convert.
fromIts unit: px, rem, em, pct (%), pt, pc, in, cm, mm, vw, vh, vmin or vmax.
rootRoot font size in px.
parentParent font size in px (for em and %).
vwViewport width in px.
vhViewport height in px.

Example: https://toolabelle.com/css-unit-converter/#value=1.5&from=rem&root=16&parent=20&vw=1440&vh=900

Related tools