Skip to main content

Convert Between CSS Length Units Convert between px, em, rem, %, vw, vh, vmin, and vmax with configurable viewport and font size.

CSS Units Converter illustration
⚖️

CSS Units Converter

Convert between px, em, rem, %, vw, vh, vmin, and vmax with configurable viewport and font size.

1

Configure context

Set your viewport dimensions, base font size, and parent element size.

2

Enter a value

Type the CSS value to convert.

3

Select units

Choose source and target CSS units.

Loading tool...

What Is CSS Units Converter?

A CSS units converter translates between the various length units available in CSS, accounting for context-dependent units. Fixed units (px) always represent the same visual size. Relative units depend on context: em and rem relate to font sizes, % relates to the parent element, and viewport units (vw, vh, vmin, vmax) relate to the browser window dimensions. This converter lets you configure all context variables (viewport size, base font size, parent size) for accurate conversions between any CSS units, making responsive design calculations quick and precise.

Why Use CSS Units Converter?

  • Configurable viewport dimensions for accurate vw/vh calculations.
  • Adjustable base font size for em/rem conversions.
  • Parent element size for percentage calculations.
  • All eight essential CSS length units.
  • Perfect for responsive design workflow.

Common Use Cases

Responsive Design

Calculate vw values for fluid typography and layouts.

Design-to-Code

Convert pixel-based design specs to responsive CSS units.

Accessibility

Convert fixed pixel sizes to relative rem units.

Layout Debugging

Understand how different CSS units translate to actual pixel sizes.

Technical Guide

CSS length units fall into two categories:

Absolute:
• px: CSS pixel (1/96 of an inch in CSS, but 1 device pixel on standard displays)

Relative:
• em: relative to element's font-size. 2em = 2× the current font-size
• rem: relative to root font-size (html element). More predictable than em
• %: relative to parent element's corresponding property value
• vw: 1% of viewport width. 100vw = full viewport width
• vh: 1% of viewport height. 100vh = full viewport height
• vmin: 1% of the smaller viewport dimension
• vmax: 1% of the larger viewport dimension

Common responsive patterns:
• Fluid typography: font-size: clamp(1rem, 2vw + 0.5rem, 2rem)
• Full-height sections: min-height: 100vh
• Responsive spacing: padding: 5vw

Tips & Best Practices

  • 1
    Use rem for font sizes (accessibility). Use px for borders and shadows (precision).
  • 2
    vmin is great for responsive square containers.
  • 3
    clamp() with vw units enables fluid typography without media queries.
  • 4
    100vh on mobile may include the address bar — use 100dvh (dynamic viewport height) instead.
  • 5
    When in doubt, start with rem and px. Add vw/vh only when you need viewport-relative sizing.

Related Tools

Frequently Asked Questions

Q How do I convert px to vw?
Divide the px value by the viewport width and multiply by 100. Example: 192px on a 1920px viewport = 192/1920 × 100 = 10vw.
Q What is the difference between vw and %?
vw is always relative to the viewport width. % is relative to the parent element, which might be smaller than the viewport.
Q When should I use rem vs em?
Use rem for consistent sizing relative to the root (no cascading surprises). Use em when you want sizing to scale with the nearest parent's font-size.
Q What is vmin?
vmin equals 1% of the smaller viewport dimension (width or height). On a 1920×1080 viewport, 1vmin = 10.8px.
Q Why do 100vh pages have scrollbars on mobile?
Mobile browsers include the URL bar in the viewport height calculation. Use 100dvh (dynamic viewport height) or JavaScript to get the actual visible height.

About This Tool

CSS Units Converter is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.