Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

CSS unit converter

This CSS unit converter turns any CSS length into every other unit at once, including inches, centimeters and viewport units. 50vw on a 1440 pixel wide viewport is 720 px, which is 45 rem.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Used for rem and em. Browsers start at 16.
Used for vw, vmin and vmax.
Used for vh, vmin and vmax.

em is taken as the same size as rem, which is right when the element's font size equals the base. Viewport units follow the width and height you type.

50 vw in px

720 pxat 16px base font and a 1,440 by 900px viewport

  • 720 px
  • 45 rem
  • 50 vw
Pixels
720 px
Inches
7.5 in
Centimeters
19.05 cm
Points
540 pt
Share of viewport width
50%
50 vw in every unit
UnitValue
px720
rem45
em45
pt540
pc45
in7.5
cm19.05
mm190.5
Q762
vw50
vh80
vmin80
vmax50

How to use the CSS Unit Converter

  1. Type the Value and pick the unit it is in under From. Choose the unit you want under To.
  2. Set the Base font size for rem and em, and the Viewport width and height for vw, vh, vmin and vmax.
  3. Read the large answer, then the chips and lines for pixels, inches, centimeters and points.
  4. Find the same length in all thirteen units in the table.

How do I convert between CSS units?

Turn the value into pixels first, then from pixels into the unit you want. The absolute units have fixed sizes: 1 inch is 96 px, 1 inch is also 2.54 cm, a point is 1/72 inch and a pica is 1/6 inch. So 1 cm is 37.7953 px, 1 mm is 3.7795 px and 12 pt is 16 px. The Q unit is a quarter of a millimeter, which makes 40 Q one centimeter.

The page does the two steps for you and rounds to four decimals, except that a value too small to show at four decimals keeps its first three digits instead of turning into 0. The result for your value appears in the table for all units, so you can switch the To menu or just read another row. A round trip returns the number you started with, apart from the rounding in the display.

Absolute units in pixels and points
LengthIn pixelsIn points
1 in96 px72 pt
1 cm37.7953 px28.3465 pt
1 mm3.7795 px2.8346 pt
1 Q0.9449 px0.7087 pt
1 pt1.3333 px1 pt
1 pc16 px12 pt

How do viewport units convert to pixels?

A viewport unit is a percent of the browser window. 1vw is 1% of its width, 1vh is 1% of its height, vmin uses the smaller side and vmax the larger. Type the real window size and the page converts for you. At 1440 by 900, 50vw is 720 px, 100vh is 900 px and 10vmin is 90 px.

The same CSS gives different pixels on different screens. The table keeps the three lengths and changes only the window. On a phone held upright 10vmin is 37.5 px, while 10vmax is 81.2 px. Rotate the phone and the two swap roles, since the long side becomes the width.

The same CSS lengths at four window sizes
ScreenWidth by height50vw10vmin10vmax
Phone375 by 812187.5 px37.5 px81.2 px
Tablet768 by 1024384 px76.8 px102.4 px
Laptop1440 by 900720 px90 px144 px
Full HD1920 by 1080960 px108 px192 px

Is a CSS centimeter a real centimeter on screen?

Not necessarily. CSS defines the inch as 96 px, and the centimeter as a fraction of that inch, so the numbers always agree with each other. A screen does not promise to draw 96 px across a real inch, because pixel density differs from device to device. A box that is 5cm wide in CSS is 188.9764 px wide, and it may measure a bit more or less with a ruler. For print styles the units line up with paper, and for screens they are a consistent scale.

Use the physical units in print stylesheets and the relative units for layouts that should follow the reader's settings. A page margin of 2cm, for example, is 75.5906 px and 56.6929 pt, and a sheet width of 8.5in is 816 px. Type those into the page to see them next to each other in every unit, then copy the one your stylesheet uses.

When do rem and em give a different answer?

Both depend on a font size, so the base font box matters. With a base of 16 px, 1.5rem is 24 px. With a base of 20 px, 24 px is 1.2 rem. This page treats em as equal to rem, which holds when the element's font size equals the base (for the font-size property itself, the parent's size counts). A nested element with its own size needs that size in the base box.

For a tool that focuses on pixel to rem work with a table of common sizes, use the px to rem converter linked below. This page is the one to open when your lengths mix inches, millimeters, points and viewport units.

Use it with

Questions

How many pixels are in an inch in CSS?

There are 96 CSS pixels in one inch, and one inch is 2.54 cm. This is a fixed definition in the CSS specification.

How do I convert cm to px?

Multiply by 96 and divide by 2.54. For 1 cm that gives 37.7953 px, and 5 cm is 188.9764 px.

What is 50vw in pixels?

It depends on the window. At 1440 px wide it is 720 px, and at 375 px wide it is 187.5 px.

What is the difference between vmin and vmax?

vmin is 1% of the smaller side of the viewport and vmax is 1% of the larger side. On a 1440 by 900 window 10vmin is 90 px and 10vmax is 144 px.

What is the Q unit?

Q is a quarter of a millimeter, so 40Q equals 1 cm.

Are my sizes uploaded?

No. The conversions run in your browser and nothing is kept after you leave.

The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.