Web Development Glossary
Glossary

Viewport Height (vh)

TL;DR: Viewport Height (vh) is a CSS unit of measurement where 1vh equals 1% of the visible browser window's height. It is essential for responsive design, allowing you to create elements (like a hero section or fullscreen modal) that reliably fill the entire screen, regardless of the device size, eliminating unwanted whitespace or scrollbars.

Stop guessing screen dimensions and use the unit that guarantees your hero sections fill the user's screen perfectly.

TL;DR: Viewport Height (vh) is a CSS unit of measurement where 1vh equals 1% of the visible browser window's height. It is essential for responsive design, allowing you to create elements (like a hero section or fullscreen modal) that reliably fill the entire screen, regardless of the device size, eliminating unwanted whitespace or scrollbars.

Why does relying on fixed pixel measurements create a fractured user experience across the thousands of different screen sizes?

What is Viewport Height (vh)?

Viewport Height is a powerful, precise tool for modern layout control. It belongs to the "viewport-relative" units family.

  • 100vh means 100% of the visible screen height.
  • 50vh means exactly half of the visible screen height.

The critical distinction is that vh is calculated based on the browser window, not the element's parent container. This makes it the most reliable way to create visually dominant, full-screen sections that adapt seamlessly from a desktop to a smartphone.

The Pain Point: The Pixel Guesswork Trap

Before vh, creating a full-screen layout required complex, unreliable, and inflexible coding:

  • Fixed Pixels (px): Setting height to 800px looks fine on a desktop but forces unnecessary scrolling on a small laptop or smartphone.
  • Parent Percentages (%): Setting height: 100% often fails because the parent element doesn't have a defined height, causing the element to collapse or behave unpredictably.
  • JavaScript Hacks: Developers often had to use JavaScript to constantly measure the screen and inject the correct pixel height, which is slow and causes layout shifts.

If you are using a basic code generator that relies on fixed units, your beautiful design will look broken on dozens of devices.

The Business Impact: Visual Dominance

Using vh correctly enhances the visual impact of your primary conversion assets.

  • High-Impact Hero Sections: Full-screen hero sections created with 100vh immediately capture the user's attention, improving storytelling and focus on your main Call-to-Action.
  • Seamless Responsiveness: By adapting to the user's actual device dimensions, you provide a smooth, premium experience, which is crucial for engagement.
  • Reduced Scroll Fatigue: Full-screen sections can present key information before requiring the user to scroll, reducing the cognitive load of browsing.

The Solution: Automated Responsive Units

You should not have to calculate the correct percentage height for dozens of containers. You need a platform that manages responsive units for you.

The best ai website builder platforms provide native control over viewport units. CodeDesign integrates vh controls directly into its visual editor. When you select a section and choose a height, the platform writes the necessary vh and related CSS, ensuring:

  1. Instant Full-Screen: One click creates a perfectly sized hero section.
  2. Cross-Browser Consistency: The system manages the unit application across different devices.

Summary

Viewport Height is an indispensable modern CSS unit for building high-impact, truly responsive layouts. It provides the only reliable way to achieve full-screen design without relying on slow JavaScript or brittle pixel values. By leveraging a platform that automates the use of vh, you eliminate layout guesswork and deploy professional, visually dominant websites instantly.

Frequently Asked Questions

Q: What is the main problem with using 100vh on mobile?

A: On some mobile browsers, the address bar or toolbar hides when scrolling, causing the viewport to shift. This makes the 100vh element appear slightly too large.

Q: What is the difference between vh and %?

A: vh is relative to the browser viewport's height. % is relative to the height of the immediate parent element. vh is better for full-screen elements.

Q: Can I use an ai website builder free tier that supports vh?

A: Yes, modern, quality builders should include access to viewport units (vh, vw) even in their free offerings, as it is a core responsive feature.

Q: What is vw used for?

A: vw is Viewport Width. It is used to size elements (especially text) based on the width of the screen, ensuring that large headlines scale down proportionally.

Q: Can I combine vh with other units?

A: Yes. For instance, you might set a banner height to 100vh - 80px to fill the entire screen minus the height of a fixed navigation bar.

Q: Does using vh affect load time?

A: No. vh is a CSS instruction and does not directly impact the website's loading speed.

Q: How does CodeDesign handle the mobile 100vh issue?

A: CodeDesign uses modern CSS and sometimes a lightweight JavaScript patch to ensure elements set to fill the viewport behave predictably on mobile devices.

Q: What are vmin and vmax?

A: vmin is the minimum of vw and vh. vmax is the maximum of vw and vh. They are used for advanced, consistent proportional scaling.

Q: Should I use vh for all vertical spacing?

A: No. Use em or rem for margins and padding within text blocks. Reserve vh for large layout divisions (hero sections, full-screen modals).

Q: How can I test my vh layout?

A: Open your browser (Chrome/Firefox) and manually drag the window's height up and down. The element set to vh should resize instantly.


Build high-impact, full-screen designs instantly

Your design should adapt perfectly to the user's device, not break. Stop the guesswork and use a precision unit.

CodeDesign.ai provides automated, visual control over Viewport Height. We handle the complex CSS, so you can build stunning, full-screen websites with guaranteed responsiveness.

Viewport Height (vh) | Web Development Glossary