← Back to all tools

📐 CSS Unit Converter

Convert between px, em, rem, pt, vw, vh, cm, mm, and in

CSS Units Explained

px — Absolute pixel unit. em — Relative to parent element's font size. rem — Relative to root (html) font size. pt — Points (1pt = 1/72 inch). vw/vh — Percentage of viewport width/height. cm/mm/in — Physical units (at 96 DPI).

Related Tools

How to Use CSS Unit Converter

  1. Enter a value in any CSS unit (px, rem, em, %, vw, vh, pt, cm)
  2. Select the source and target units
  3. Set the root font size (default 16px) for rem calculations
  4. View the converted value instantly
  5. Copy the result for your stylesheet

About CSS Unit Converter

CSS supports numerous units and knowing when to use each is crucial for responsive design. Pixels (px) are absolute and predictable. Rem is relative to the root font size — ideal for consistent scaling across components. Em is relative to the parent element's font size — useful for component-internal spacing. Viewport units (vw/vh) scale with the browser window — perfect for full-screen sections and fluid typography. Percentages are relative to the parent element. Points (pt) and centimeters (cm) are for print stylesheets. This converter handles bidirectional conversion between all common CSS units, accounting for the base font size that affects rem/em calculations. Essential for migrating legacy px-based designs to modern responsive rem-based systems.

Frequently Asked Questions

Should I use px or rem?

Use rem for typography and spacing — it respects user font-size preferences and scales consistently. Use px for borders, shadows, and decorative details where exact sizing matters. Most modern CSS frameworks use rem as default.

What's the default root font size?

Browsers default to 16px root font size. So 1rem = 16px, 0.875rem = 14px, 1.25rem = 20px. Some developers set html { font-size: 62.5% } to make 1rem = 10px for easier mental math.

When should I use viewport units?

vw/vh are ideal for full-screen hero sections (height: 100vh), fluid typography (font-size: 3vw), and responsive spacing. Be careful: 100vh on mobile doesn't account for browser chrome — use 100dvh (dynamic viewport height) instead.

What's the difference between em and rem?

rem is always relative to the html element's font size (consistent everywhere). em is relative to the current element's parent font size (compounds with nesting). rem is generally preferred for its predictability; em is useful for component-relative sizing.

How do I convert a px-based design to rem?

Divide px values by 16 (or your root font size). 24px = 1.5rem, 14px = 0.875rem, 48px = 3rem. This converter does the math instantly. Consider using a CSS preprocessor function for batch conversion in large codebases.

Related Tools

Screen Resolution Detector → Aspect Ratio Calculator → CSS Border Generator → Border Radius Preview →