CSS Unit Converter
Convert between CSS units like px, em, rem, vw, vh, and percentages with configurable viewport.
Input Value
Context Settings
Conversion Results
Quick Reference
1rem = 16px (root font-size)1em = 16px (parent font-size)1vw = 19.20px (1% of 1920px)1vh = 10.80px (1% of 1080px)1pt = 1.3333px (1/72 of an inch)1in = 96px (at 96 DPI)1cm = 37.7953px1mm = 3.7795pxRelated Tools
EM/REMNEW
Convert between px, em, and rem CSS units with configurable base font size. Includes conversion table and CSS output.
Aspect RatioNEW
Calculate aspect ratios for images and videos. Enter width or height with a ratio (16:9, 4:3, 1:1) to find the other dimension.
CSS Beautifier
Format and beautify messy CSS code. Minify or expand with proper indentation.
CSS Grid
Visual CSS Grid layout builder. Set rows, columns, and gaps with live preview.
Frequently Asked Questions
What is the difference between px and rem?
When should I use rem vs em?
What are viewport units (vw, vh)?
How do I convert px to rem?
What is the difference between absolute and relative units?
Why should I use relative units for font sizes?
How to Use the CSS Unit Converter
CSS offers many different units for specifying sizes, and converting between them is a common task in web development. Our converter handles all major CSS units and provides a complete conversion table so you can see the equivalent value in every unit at once.
Step 1: Enter a value and select its unit. Type a numeric value and choose its current unit (px, rem, em, vw, vh, %, pt, cm, mm, or in). The converter immediately calculates the equivalent in all other units.
Step 2: Configure your context. Set the base font size (default 16px) and viewport dimensions (default 1920x1080). These settings affect the conversion of relative units like rem, em, vw, and vh. Match these to your actual project settings for accurate conversions.
Step 3: View the conversion table. The complete conversion table shows the entered value converted to every supported unit. Copy any value directly from the table for use in your CSS code.
Understanding CSS Units
CSS units fall into two categories: absolute units that have fixed sizes, and relative units that depend on context. Absolute units include px (pixels), pt (points, 1pt = 1/72 inch), cm (centimeters), mm (millimeters), and in (inches). These are useful when you need precise, fixed sizes regardless of the viewing context.
Relative units include rem (relative to root font size), em (relative to parent font size), vw and vh (relative to viewport dimensions), and % (relative to parent element size). Relative units are the foundation of responsive web design because they adapt to different screen sizes, user preferences, and context.
CSS Unit Best Practices
Font sizes: use rem. Setting font sizes in rem ensures they scale with the user's browser preferences and your global font size settings. A common pattern is to set html font-size to 62.5% (making 1rem = 10px) for easier calculations, then use rem values like 1.6rem for 16px, 2.4rem for 24px, and so on.
Spacing: use rem or em. Margins and padding should typically use rem for consistent spacing across the layout, or em for component-relative spacing. Using rem for spacing ensures that your layout scales proportionally when the base font size changes, maintaining visual harmony.
Borders and shadows: use px. Thin lines like borders and subtle shadows often look best at fixed pixel sizes. A 1px border should remain 1px regardless of font size. Using px for these decorative elements ensures they stay crisp and consistent.
Full-screen layouts: use viewport units. For hero sections, full-screen overlays, and viewport-relative layouts, use vw and vh. However, consider using dvh (dynamic viewport height) on mobile to account for the changing address bar height. Viewport units combined with min() and max() functions create robust responsive layouts.