Home/Developer Tools/CSS Unit Converter
📏

CSS Unit Converter

FREE

px, rem, em, %, vw and vh against a chosen base

Free · No sign-up required
Loading...

What the CSS unit converter does

CSS lengths come in absolute units (px) and several relative ones — rem, em, %, vw, vh — that depend on a base value. This converter translates between them for a given base: root font size for rem, parent font size for em, parent width for %, and a viewport size for vw and vh. Enter a value in one unit and read it in the others. It runs in your browser and is the quick answer to “what is 1.25rem in pixels?” or “how many vw is 320px on a 1920 screen?”.

The formulas

px = rem × root font size (default 16px) px = em × parent font size px = % × parent dimension ÷ 100 px = vw × viewport width ÷ 100 px = vh × viewport height ÷ 100 24px = 1.5rem (at 16px root) 1.25rem = 20px 320px on a 1920px viewport = 16.67vw 50vh on a 1080px viewport = 540px

Which unit, when

UnitRelative toUse forAvoid for
pxNothing — fixedBorders, shadows, hairlines, media-query breakpointsFont sizes (ignores user preferences)
remRoot font sizeFont sizes, spacing, layout widths — scales with user settingsThings that must never scale (1px borders)
emParent / own font sizePadding and margins inside components, icon sizes next to textDeep nesting — compounds unpredictably
%Parent's corresponding dimensionFluid widths, image sizing within containersHeights (parent often has no set height)
vw / vhViewport width / heightFull-screen sections, fluid type with clamp()Anything on mobile where 100vh includes hidden browser UI — use dvh/svh

Common rem values at 16 px root

pxremTypical use
120.75Captions, labels
140.875Secondary text, UI
161Body text
181.125Lead paragraphs
201.25H4
241.5H3
322H2
483H1, hero
4 / 8 / 16 / 24 / 320.25 / 0.5 / 1 / 1.5 / 2Spacing scale

Why rem is the default for type and spacing

Users who set a larger default font size in their browser — common among people with low vision — get larger text only if sizes are in rem or em. Pixel font sizes ignore that setting entirely. A layout built on rem scales coherently: type, spacing and container widths grow together. Borders, shadows and other decorations that should stay hairline-thin are the reasonable exception and stay in px.

The 62.5% trick and why it is mostly gone

Setting html { font-size: 62.5% } makes 1rem = 10px, so 1.6rem = 16px and the mental arithmetic is easier. It was popular for years but has fallen out of favour: it changes the root size that third-party components and user stylesheets rely on, and modern editors and design tools display rem values directly. Most current systems keep the root at the browser default (16px) and use a converter like this one when they need the pixel equivalent.

Fluid type with clamp()

font-size: clamp(1rem, 0.5rem + 1.5vw, 2rem); /* 16px minimum, grows with viewport, 32px maximum */

Mixing rem and vw in clamp() gives text that scales between breakpoints without media queries. The converter helps pick the vw coefficient: decide the pixel size at two viewport widths and solve for the slope.

Frequently asked questions

Is 1rem always 16px?

By default in all browsers, yes — unless the user has changed their default font size or the site sets a font-size on html. The converter lets you set the root size to match.

What is the difference between em and rem?

rem is relative to the root element only; em is relative to the current element's font size (inherited from the parent). em compounds when nested; rem does not.

Why is 100vh wrong on mobile?

Mobile browsers' address bars show and hide, changing the visible area. 100vh uses the largest size, so content is cut off when the bar is visible. Use 100dvh (dynamic) or 100svh (small) instead.

Should breakpoints be in px, em or rem?

em or rem breakpoints scale with the user's font size, which many consider more robust; px breakpoints are more common and easier to reason about. Both are acceptable; be consistent.

How do I convert pt (points) from a design file?

1pt = 1.333px in CSS (96px per inch, 72pt per inch). Most design tools already export px.

Are my values sent anywhere?

No. The conversion runs in your browser.

More tools in this category

🌈
CSS Gradient Generator
Build linear, radial and conic gradients and copy the CSS
🪟
CSS Glassmorphism Generator
Frosted-glass panels with backdrop-filter, tint and border
CSS Clip-Path Generator
Circle, polygon, star and custom shapes as clip-path values
📈
CSS Cubic-Bezier Generator
Drag handles to design easing curves for transitions
CSS Loader Generator
Spinner, dots, bars, pulse and bounce loaders in pure CSS
🖱
CSS Button Generator
Design buttons with hover, active and focus states