Quickly convert CSS viewport height (vh) units to pixels (px) with this efficient tool. VH is a relative unit based on your screen's visible area, while PX is a fixed unit. Simplify your web design measurements with this handy VH to PX converter.
Viewport height (vh) is a CSS unit that represents a percentage of the visible screen space. It refers to the viewable area of a device’s screen, whether on a desktop, laptop, tablet, or smartphone.
Viewport height (vh) is a CSS unit that defines a percentage of the visible screen space. Unlike pixels (px), which are fixed units, vh
adapts dynamically based on the device's screen size.
Use this simple formula to manually convert PX to VH:
Let’s say you’re working with a device viewport of 430px × 932px (iPhone 14 Pro Max). The viewport height is 932px.
Now, converting 50vh to pixels:
(932 ÷ 100) × 50 = 466px
So, 50vh is equal to 466px on this specific device.
You can easily retrieve the viewport height of a webpage using JavaScript. The window
object provides an attribute called innerHeight
, which returns the viewport height in pixels.
console.log(window.innerHeight); // Outputs the viewport height in pixels
This allows you to dynamically calculate and adjust elements based on the user's screen size.
There are several practical use cases for vh
in web design:
To make the header stay at the top and the footer stick at the bottom, even on a blank page, use:
body {
height: calc(100vh - footerpx - headerpx);
}
This ensures a responsive, full-screen layout.
If you need to determine whether an image or iframe will fit within 60vh
, use JavaScript:
const sixtyVhInPx = (window.innerHeight / 100) * 60;
console.log(sixtyVhInPx); // Check if content exceeds this height
Below is a reference table comparing common Pixels on popular devices against specific pixel values.
vh | iPhone 12 Pro (844px) | iPad Pro 12.9" (1366px) | Samsung Galaxy S9+ (740px) |
---|---|---|---|
10vh | 84.4px | 136.6px | 74px |
20vh | 168.8px | 273.2px | 148px |
30vh | 253.2px | 409.8px | 222px |
40vh | 337.6px | 546.4px | 296px |
50vh | 422px | 683px | 370px |
60vh | 506.4px | 819.6px | 444px |
70vh | 590.8px | 956.2px | 518px |
80vh | 675.2px | 1092.8px | 592px |
90vh | 759.6px | 1229.4px | 666px |