OhMyCalc

CSS Unit Converter

Convert between CSS units: px, rem, em, vw, vh, and %. Configure base font size and viewport dimensions for accurate results.

Settings

All Equivalents

UnitValue
px16px
rem1rem
em1em
vw0.833333vw
vh1.48148vh
%100%
= 16 px

Quick Reference (px → rem)

pxrememvwvh
8px0.5rem0.5em0.416667vw0.740741vh
12px0.75rem0.75em0.625vw1.11111vh
14px0.875rem0.875em0.729167vw1.2963vh
16px1rem1em0.833333vw1.48148vh
18px1.125rem1.125em0.9375vw1.66667vh
20px1.25rem1.25em1.04167vw1.85185vh
24px1.5rem1.5em1.25vw2.22222vh
32px2rem2em1.66667vw2.96296vh
48px3rem3em2.5vw4.44444vh
64px4rem4em3.33333vw5.92593vh

How to Convert CSS Units

  1. Set your base font size (default: 16px) and viewport dimensions
  2. Enter a value and select its unit (px, rem, em, vw, vh, or %)
  3. View all equivalent values in other CSS units
  4. Check the quick reference table for common px-to-rem conversions

حالات الاستخدام

الصيغة

CSS unit conversions depend on the base font size and viewport dimensions. rem = px / baseFontSize. vw = px / viewportWidth × 100. vh = px / viewportHeight × 100.

الأسئلة الشائعة

What is the difference between rem and em?
rem is relative to the root (html) font size. em is relative to the parent element's font size. At the root level, they are identical.
What is the default browser font size?
Most browsers default to 16px. This means 1rem = 16px unless the root font size is changed.
When should I use vw/vh?
Use vw (viewport width) and vh (viewport height) for elements that should scale proportionally to the browser window, like hero sections or full-screen backgrounds.
How do I convert px to rem?
Divide the pixel value by the base font size. With default 16px: 24px ÷ 16 = 1.5rem.
What is the % unit relative to?
The % unit is context-dependent in CSS. For font-size, it's relative to the parent's font-size. For width, it's relative to the parent's width.