Three classes of CSS length
Absolute units tie to physical size — px, pt, in, cm, mm. Relative units tie to a reference — rem to the root font size, em to the current one, vw and vh to the viewport, percentages to the parent. Conversion means finding the reference and multiplying. Enter a value and a starting unit, supply root size, viewport width and height, and six units come back at once.
Steps
- Enter the value, then the root font size, sixteen by default.
- Enter viewport width and height so vw and vh resolve.
- Enter the em reference size, usually the current element's own.
- Choose the source unit among px, rem, em, pt and in, then calculate.
- Copy the six-unit result or load the example.
The fixed conversions
One inch is ninety-six pixels by CSS specification, independent of the display. So one point is 96/72, about 1.333 pixels; one inch is 96; one centimetre about 37.8; one millimetre about 3.78. rem depends on root size: 16px root means 1rem is 16px, while a 10px root makes it 10px. vw and vh divide the viewport, so 1440 wide means 1vw is 14.4px.
Choosing units
Fixed dimensions use px — one-pixel borders, twenty-four-pixel icons. Spacing that follows type uses em or rem, such as 1.5× line spacing. Page layout uses rem so users rescaling the root scales everything. Viewport-dependent widths use vw or percentages, though mobile browser chrome changes viewport height, making vh unreliable there; svh and dvh exist for that. Print styles use pt and cm because print is physical.
Common misconceptions
Treating px as a physical pixel ignores that high-density screens map one CSS pixel to several device pixels. Using rem as em compounds through nesting until type collapses. Setting width to 100vw plus a scrollbar produces horizontal scrolling; subtract the scrollbar or use percentages. pt on screen is only a conversion, not a physical measure. And converting sizes while leaving line heights at old values breaks vertical rhythm.
When conversion is unnecessary:Flex, grid, gap and clamp let the browser compute most sizes. Strict pixel alignment for graphics and borders wants px; converting to rem invites half-pixel blur. Between design specs and implementation a fixed ratio — a 2× mockup halved at build time — beats per-value arithmetic. The tool earns its place when inheriting unfamiliar code, converting print styles for screen, and checking what a rem value actually resolves to.