Ttooleras
📏

CSS Unit Converter

CSS Tools

Convert between CSS units — px, rem, em, vw, vh, %, pt, cm — for responsive design. Free, private — all processing in your browser.

px
16.00
rem
1.0000
em
1.0000
pt
12.00
vw
0.8333
vh
1.4815
%
100.00
cm
0.4233
mm
4.2333
in
0.1667

Quick Reference (base: 16px)

8px
0.500rem
10px
0.625rem
12px
0.750rem
14px
0.875rem
16px
1.000rem
18px
1.125rem
20px
1.250rem
24px
1.500rem
28px
1.750rem
32px
2.000rem
36px
2.250rem
40px
2.500rem
48px
3.000rem
56px
3.500rem
64px
4.000rem
72px
4.500rem
Advertisement

The CSS Unit Converter translates between every CSS length unit: px (pixels), rem (root em), em (element em), vw/vh/vmin/vmax (viewport units), % (percentage), pt/pc (print units), cm/mm/in (physical units), ch (character width), ex (x-height), lh (line height), and modern dvh/svh/lvh (dynamic viewport units). Set the root font size (default 16px) and see how 1rem relates to every other unit. Essential for responsive design decisions: when to use rem vs em, px vs vw, %; for creating fluid typography with clamp(); for accessibility-respecting font sizes that scale with user preferences.

Understanding CSS units is the foundation of responsive, accessible design. Many developers default to px for everything, losing the benefits of rem (scales with user font size) or vw (scales with viewport). This converter makes the relationships concrete — see exactly what 1.5rem equals in pixels at different root sizes, what 50vw equals on different screen widths, and when each unit is appropriate. Pair with our other CSS tools for a complete responsive toolkit.

CSS Unit Converter — key features

All CSS units supported

px, rem, em, vw, vh, vmin, vmax, %, pt, pc, cm, mm, in, ch, ex, lh, dvh, svh, lvh, cqw, cqh.

Configurable root font size

Change from default 16px to see how conversions shift. Essential for teams using custom html font-size.

Configurable viewport size

Set viewport dimensions to calculate vw/vh. Preview mobile vs desktop vs tablet.

Element context

For em units, set the element font-size to calculate actual em value.

Conversion table

One value, all units. See how 16px equals to rem, em, pt, vw, etc.

clamp() helper

Build fluid typography with clamp() — enter min and max, tool calculates the preferred value.

Batch conversion

Convert a list of values at once (e.g., all spacing in your design system).

Copy CSS

Ready-to-use values for your stylesheet.

How to use the CSS Unit Converter

  1. 1

    Set root font-size

    Default 16px (browser default). Some designs use 10px for easier rem math.

  2. 2

    Enter value and unit

    Type the value, select the unit (e.g., 24 px or 1.5 rem).

  3. 3

    See conversions

    Tool shows equivalent in all other units. Useful for matching design specs.

  4. 4

    For em: set element font-size

    em is relative to the element. Set its font-size for accurate em conversion.

  5. 5

    For vw/vh: set viewport

    Enter viewport dimensions to see how vw/vh values resolve.

  6. 6

    Copy the unit you need

    Each unit has a copy button. Paste into your CSS.

Common use cases for the CSS Unit Converter

Responsive design

  • Convert design-to-code: Designers provide values in px (Figma, Sketch). Developer converts to rem/em for responsive behavior.
  • Fluid typography: Build clamp() expressions for headings that scale with viewport. Tool helps find the right min/max/preferred values.
  • Mobile viewport heights: Convert between vh and dvh — the newer dynamic viewport unit handles mobile browser UI correctly.
  • Responsive spacing: Convert fixed px spacing to rem so they scale with user font preferences.

Accessibility

  • rem for user preference: Users with larger font preferences get larger sites only if rem/em used. Converting px to rem improves accessibility.
  • ch for readable width: Body text max-width around 65ch for optimal reading. Tool converts to px for testing.
  • Relative font sizing: Heading hierarchies with ratios (1rem, 1.25rem, 1.5rem, 2rem) maintain relationships when user changes font size.

Print styles

  • Screen to print conversion: Convert px values to pt for print stylesheets.
  • Physical unit accuracy: Convert screen px to cm or in for truly physical measurement.
  • Print typography: Body text in 10-12pt for print, equivalent to 13-16px on screen.

Development

  • Design system audits: Convert legacy px values to rem throughout your codebase.
  • Cross-team communication: Designer says 24px, developer uses 1.5rem. Tool bridges the language.
  • Legacy refactoring: Move old px-based CSS to modern responsive units batch by batch.
  • Code review tool: Quick check: is this 1.5rem reasonable? Tool shows the px equivalent instantly.

CSS Unit Converter — examples

16px to rem

Standard conversion, root = 16px.

Input
16px, root 16px
Output
1rem

24px to rem

Common heading size.

Input
24px, root 16px
Output
1.5rem

1.5rem to px

Reverse direction.

Input
1.5rem, root 16px
Output
24px

100vh to px

Full viewport height.

Input
100vh, viewport 900px tall
Output
900px

50vw with responsive breakpoints

How half-width scales.

Input
50vw at multiple sizes
Output
Mobile (360px): 180px
Tablet (768px): 384px
Desktop (1440px): 720px

Fluid typography with clamp

Scalable heading.

Input
Min 1rem, max 2rem, preferred 2vw + 0.5rem
Output
font-size: clamp(1rem, 2vw + 0.5rem, 2rem);

At viewport 400px: 0.5rem + 0.5rem = 1rem (min)
At viewport 1200px: 2rem (max, capped)

ch for readable width

Max-width for body prose.

Input
65ch, font-family default
Output
65ch ≈ 520px (varies by font)

.prose {
  max-width: 65ch;
}

dvh for mobile

Full-height modal respecting address bar.

Input
100dvh
Output
.modal {
  height: 100dvh; /* Adjusts with mobile browser UI */
}

Technical details

CSS units fall into several categories:

Absolute units (fixed size):

- px — pixels. On screens, 1px is the reference unit (actual size depends on device DPI). 1 CSS px ≈ 1/96 inch in print.
- pt — points. 1pt = 1/72 inch. Used in print. 1pt = 1.33px.
- pc — picas. 1pc = 12pt = 16px.
- cm, mm, in, Q — physical units. 1cm = 37.8px. Mainly for print stylesheets.

Relative to font size:

- em — size of the current element font-size. 1em = element's font-size. Nested elements stack (child em is based on parent em).
- rem — size of the root element (html) font-size. 1rem = 16px by default. Consistent regardless of nesting.
- ch — width of the "0" character of the element's font. Useful for max-width based on readability.
- ex — x-height of the element font. Rarely used.

Relative to viewport:

- vw — 1% of viewport width. 50vw = half the window width.
- vh — 1% of viewport height. 100vh = full window height.
- vmin — 1% of smaller viewport dimension.
- vmax — 1% of larger viewport dimension.
- dvh / svh / lvh — dynamic, small, large viewport height (accounts for mobile browser UI — address bar showing/hiding).
- cqw / cqh — container query units (relative to parent container).

Relative to parent:

- % — percentage of parent's corresponding dimension (width% is % of parent width, height% of parent height).

Typical use cases per unit:

| Unit | When to use |
|---|---|
| px | Fixed sizes: borders, small icons, shadows |
| rem | Font sizes, margins, padding (scalable) |
| em | Element-relative (line-height, padding on buttons matching font size) |
| % | Widths relative to parent |
| vw/vh | Full-viewport sections, fluid typography |
| ch | max-width for readable prose (~65ch) |
| dvh | Full mobile viewport height (accounts for address bar) |

Conversion reference (root = 16px):

| Units | px equivalent |
|---|---|
| 1rem | 16px |
| 1em (default) | 16px |
| 1pt | ~1.33px |
| 1pc | 16px |
| 1cm | ~37.8px |
| 1in | 96px |
| 1vw (1080px viewport) | 10.8px |
| 1vh (1080px viewport) | 10.8px |

Fluid typography with clamp():

clamp(min, preferred, max) creates fluid values:

``css
font-size: clamp(1rem, 2vw + 0.5rem, 2rem);
/* Scales with viewport but clamps at 1rem-2rem */
``

Accessibility considerations:

- User font size preferences: Users can change browser default font size. Using rem/em respects this; px does not.
- Root font-size shouldn't be pixel-fixed: Setting html { font-size: 16px } overrides user preference. Better: use browser default or percentage (html { font-size: 100% }).
- Icon/border sizes in px are OK: they do not need to scale with text preference.

Container queries (CSS Container Queries, 2023):

New units cqw, cqh, cqi, cqb, cqmin, cqmax relative to container, not viewport. Powerful for component-based responsive design.

Modern viewport units (2022+):

Mobile browsers dynamically show/hide UI (address bar). Old vh is based on large viewport (bar collapsed). New units:

- svh — small viewport height (address bar visible)
- lvh — large viewport height (address bar hidden)
- dvh — dynamic viewport height (current state)

Use dvh for elements that should fill the viewport at any moment: height: 100dvh.

Common problems and solutions

em compounds through nesting

Child element with em inherits parent em. Set font-size: 1.2em on parent then child, child em based on parent em. Use rem for consistency across nesting levels.

100vh issues on mobile

Classic vh uses large viewport (address bar hidden). On mobile with bar visible, 100vh creates overflow. Use dvh for dynamic viewport that adjusts with browser UI.

px does not respect user preferences

Users can change browser default font size for accessibility. px ignores this; rem/em scales with user preference. Use rem for text-related values (font-size, line-height, typography margins).

Setting html font-size in px overrides user

html { font-size: 16px } overrides user's accessibility preference. Better: use 100% (default) or use percentage for explicit override while still respecting ratios.

% is relative to parent property

width: 50% is 50% of parent width. margin: 5% is 5% of parent WIDTH (not height). Check what % is relative to — varies by property.

vw/vh for fixed-size elements

Icons, borders — use px. vw/vh scale with viewport which may make borders 0.5px (invisible) or way too thick. Reserve vw/vh for layout-level sizing.

Mixing unit types without thinking

Inconsistency across codebase (some px, some rem, some em) makes maintenance hard. Pick a convention: rem for text and spacing, px for borders and icons. Stick to it.

clamp() with wrong order

clamp(min, preferred, max) — order matters. min must be less than max. If preferred never reaches min, min is used; if exceeds max, max is used. Easy to misunderstand.

CSS Unit Converter — comparisons and alternatives

rem vs em: rem is always relative to root (html) font-size — consistent. em is relative to current element font-size — compounds through nesting. Use rem for most things (font-size, margin, padding). Use em only when you want child to scale with parent element size.

px vs rem for font-size: px is fixed, ignores user accessibility font preference. rem scales with user preference. For body text and UI text, use rem for accessibility. For fine details (borders, shadows), px is fine.

vw/vh vs %: vw/vh are relative to viewport (full screen). % is relative to parent. For fluid layouts, % is more common. For full-screen hero sections, vh/vw.

vh vs dvh: vh is large viewport (mobile bar hidden). dvh is dynamic (current state including bar). For mobile full-height elements, use dvh to avoid overflow when bar is visible.

ch vs px for max-width: ch is relative to character width (scales with font). px is fixed. For readable prose width, 65ch is the sweet spot — roughly 65 characters per line. Better than arbitrary px.

pt vs px: pt is for print (1pt = 1/72 inch). px is for screens. Print stylesheets use pt, screen stylesheets use px. Both are absolute units.

Frequently asked questions about the CSS Unit Converter

What is the difference between rem and em?

rem is always relative to root element font-size (html, default 16px). em is relative to the current element font-size. Example: in a parent with font-size: 2rem (32px), 1em on child = 32px; 1rem on child = 16px. Use rem for consistency, em for element-relative scaling.

Should I use px or rem for font-size?

rem for most cases. rem respects user accessibility preference (browser default font size). px ignores it, which hurts users who need larger text. For body text and UI labels, use rem. For fine details (hairline borders, icon sizes), px is fine.

What is a typical root font-size?

16px is the default in all browsers. Some designers use 10px (set html { font-size: 62.5% }) for easier math — 1rem = 10px, 1.6rem = 16px. Both approaches work.

When should I use vw/vh?

vh for full-viewport heights (hero sections). vw for full-viewport widths. Fluid typography with viewport-relative scaling. Avoid for fixed-size UI elements (icons, borders) — they scale unpredictably.

What is dvh and should I use it?

dvh (dynamic viewport height, 2022+) adjusts as mobile browser UI (address bar) shows/hides. Use dvh for 100% mobile viewport elements — avoids overflow when address bar appears. 100vh causes issues on mobile.

What is ch unit useful for?

ch is width of the 0 character in the current font. Useful for max-width on body prose — 65ch is ideal line length for reading. As font changes, width adjusts. More semantic than arbitrary px.

How do I do fluid typography?

Use clamp(min, preferred, max): font-size: clamp(1rem, 2vw + 0.5rem, 2rem). Scales linearly with viewport between breakpoints. Modern browsers support natively. Tool helps compute right values.

What are container query units?

cqw, cqh, cqi, cqb, cqmin, cqmax are relative to container (parent with container-type set), not viewport. Powerful for components that adapt to their container size regardless of viewport. 2023+.

Why does my em compound through nesting?

By design. em is relative to current element's font-size, which inherits and multiplies. Grandparent 1.2em, parent 1.2em, child 1.2em = 1.728 * base. Use rem to avoid compounding.

Which unit is best for margin/padding?

rem for most cases. Scales with user font preference, creates consistent rhythm. px for fine details (1px borders). % when you want proportional spacing relative to parent. em for spacing matching current element font-size (e.g., button padding matching button font-size).

Additional resources

Advertisement

Related tools

All CSS Tools

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →