What is vh in html

Last updated: April 1, 2026

Quick Answer: VH is a CSS unit of measurement where 1vh equals 1% of the browser's viewport height, enabling responsive design that adapts to different screen sizes without JavaScript.

Key Facts

Understanding Viewport Height

Viewport Height (VH) is a CSS unit that provides a way to size elements relative to the browser's visible window height. Unlike fixed pixels or percentages that reference parent elements, VH measurements are calculated based on the actual screen space available to the user. When you specify an element as 100vh, it will be exactly as tall as the current browser window, making it ideal for creating full-screen sections without JavaScript calculations.

Common Uses of VH

VH units are extensively used in modern web design for several key purposes:

VH vs Other CSS Units

Understanding the difference between VH and other measurements is crucial for choosing the right unit:

Browser Support and Considerations

Modern browsers provide excellent support for VH units. However, mobile browsers sometimes calculate VH differently, including or excluding the browser's address bar in their calculations. This can cause unexpected behavior, which developers address using viewport meta tags and careful testing. The CSS Working Group continues to refine viewport unit specifications to ensure consistent cross-browser behavior.

Related Questions

What is vw in CSS?

VW is a CSS unit equal to 1% of the viewport width, used similarly to VH but for horizontal measurements. It's useful for creating responsive widths that adapt to screen size.

How is VH different from percentages in CSS?

Percentages are relative to parent element dimensions, while VH is relative to the browser window height. VH creates full-screen effects more easily, whereas percentages depend on parent element sizing.

Can I use VH for mobile devices?

VH works on mobile devices but behaves differently than desktop due to browser UI elements. Mobile browsers may include or exclude address bars in viewport calculations, requiring testing and sometimes alternative approaches.

Sources

  1. MDN Web Docs - CSS values and units CC-BY-SA-2.5
  2. W3C - CSS Values and Units Module Level 3 W3C