1fb69f117379804f644a
·1 min read

Understanding Viewport Heights

css
responsive design
4d5fd787ac74e0caa4f7

Sohan R. Emon

Developer, Learner, Tech Enthusiast

Viewport Heights (VH) are a handy way to size elements in a web page relative to the height of the user's screen. Here are some common VH units:

  • vh (Viewport Height): Represents a percentage of the viewport's height. For example, 50vh is half the height of the viewport.

  • dvh (Dynamic Viewport Height): Serves as a dynamic value that can change based on the content. It adapts to the height needed by the content within it.

  • svh (Small Viewport Height): Refers to a smaller portion of the viewport's height, often used for smaller screens or mobile devices.

  • lvh (Large Viewport Height): Denotes a larger portion of the viewport's height, suitable for larger screens or desktops.

Cheat sheet

UnitName
vhViewport Height
dvhDynamic Viewport Height
svhSmall Viewport Height
lvhLarge Viewport Height

These units are useful for creating responsive web designs that adapt to various screen sizes.

Found this useful?