← All text tools

CSS Viewport and Percentage Unit Converter

Convert pixels to vw, vh, vmin, vmax and percent of a parent size, or back to pixels, from your viewport and parent dimensions, with a CSS snippet.

  • Free
  • No sign-up
  • Works on any device

About CSS Viewport and Percentage Unit Converter

CSS has units that depend on the screen and on the parent element, and pixels do not convert to them without extra numbers. Enter a pixel value together with the viewport width and height and the parent width and height, and get the matching vw, vh, vmin, vmax and percentage values with ready CSS lines. The other direction turns vw, vh or percent into pixels. Example: 360 px on a 1440 by 900 viewport is 25vw, 40vh, and 45% of an 800 px parent. A percentage height only works when the parent has a set height.

How to use CSS Viewport and Percentage Unit Converter

  1. Choose pixels to units, or units to pixels.
  2. Enter the value and your viewport and parent sizes in pixels.
  3. Copy the unit you need from the table, or the whole CSS snippet.

Why use this tool?

Also known as

Frequently asked questions

What is the difference between vw and a percentage width?

vw is a share of the viewport width, wherever the element sits. A percentage width is a share of the parent element's content width, so it changes when the parent changes size.

What are vmin and vmax?

vmin is 1 percent of the smaller viewport side and vmax is 1 percent of the larger one. On a phone held upright vmin follows the width, and after rotating it follows the height.

Why does a percentage height sometimes do nothing?

A percentage height is resolved against the parent's height. If the parent's height depends on its content, there is nothing to take a percentage of, so the browser treats it as auto.

Is CSS Viewport and Percentage Unit Converter free?

Yes. CSS Viewport and Percentage Unit Converter on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.