Skip to content
UniKit

Viewport unit calculator

Semantics and pixel maths for vw, vh, vmin, vmax, vb, vi, svh, lvh, dvh, svw, lvw and dvw: your viewport size turns into real numbers such as 1vw = 3.9px or 50vh = 422px, with 100vh / 100svh / 100lvh / 100dvh compared side by side. The same page converts rem, em and percentages from the root font size, the parent font size and the parent box, and hands you the CSS variables and fallback snippets. Pure arithmetic — no file needed.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Conversion

The conversion is shown as text below.

Conversion result

The viewport size, root font size and parent box are the real numbers you entered; the tables below convert them to px.

Fill in the viewport size to convert.

What this tool does

  • Work out the numbers before writing responsive CSS: in a 390 × 844 phone viewport, 50vh is 422px and 1vw is 3.9px.
  • Debug the mobile 100vh problem: fill in the large, small and dynamic heights and the table shows 100vh = 844px, 100svh = 780px, 100dvh = 810px and the differences.
  • Convert rem / em / %: enter the root font size and the parent box to get 1rem = 16px, 1em = 16px and 1% width = 12px without mental arithmetic.
  • Copy the CSS straight out: the page hands you the :root variables, the svh-fallback + dvh-exact full-height snippet and the legacy --app-height fallback.

Example

Input

Value 50, unit vh, viewport 390 × 844 (small 780, dynamic 810), root font size 16, parent box 1200 × 800

Output

Conversion: 50 vh = 422 px
Unit: vh · 1% of viewport height
Viewport 390 × 844 px (small svh 780, dynamic dvh 810)
Root font size 16 px → 1rem = 16 px
Parent font size 16 px → 1em = 16 px
Parent box 1200 × 800 px → 1%w = 12 px, 1%h = 8 px
Viewport units (unit / 1 unit / 100 units / 50 units, px)
  vw: 3.9 / 390 / 195 px
  vh: 8.44 / 844 / 422 px
  vmin: 3.9 / 390 / 195 px
  vmax: 8.44 / 844 / 422 px

Those are the first twelve rows the page prints; the full report adds the tables for all 12 viewport units and 5 relative units, the 100vh comparison (100svh is 64 px shorter than the large viewport) and three copy-ready CSS snippets.

Frequently asked questions

What is the basis of each unit?

1vw = layout viewport width ÷ 100; 1vh = 1lvh = large viewport height ÷ 100; 1svh = small viewport height ÷ 100; 1dvh = current visible height ÷ 100; 1vmin = min(width, height) ÷ 100 and 1vmax = max(width, height) ÷ 100; vi / vb follow the writing mode (equal to vw / vh in horizontal text). So “1vw in pixels” depends entirely on the width you enter, and every number on the page is computed from your inputs.

What are rem, em and % based on?

1rem = the font size of the root element (<html>), 16px by default; 1em = the font size that element inherits, which compounds down the tree — hence the “parent font size” input. Percentages have no single basis: width-like properties resolve against the parent width and height-like ones against the parent height, so the tool lists %w (parent width ÷ 100) and %h (parent height ÷ 100) separately instead of a vague “1% = ?px”.

What is the 100vh problem and why is my footer covered?

By specification vh equals the large viewport height (the size with the browser UI retracted), while the visible area is shorter while the toolbar is expanded. So 100vh is taller than what you see and the bottom gets hidden or a scrollbar appears. The table turns that into numbers: on a 390 × 844 device 100vh = 844px and 100dvh = 810px, a 34px gap. The usual fix is a 100svh fallback overwritten by 100dvh — the page has the snippet ready to copy.

Does this tool need a file?

No, and it does not offer a file picker: it is plain arithmetic between CSS units and px, with the viewport size, root font size and parent box all typed in. Everything runs in your browser with no requests.

How do I choose between svh, lvh and dvh?

Use svh when content must be fully visible (onboarding, sign-in, buttons that must not be covered); lvh / vh when the block only needs to look full-bleed and a little cropping is fine (backgrounds, decorative images); dvh when it must hug the visible area exactly (full-screen dialogs, drawers, video containers) — but it changes while scrolling, which can cause reflows.

Do these units still matter on desktop?

Yes. Browser zoom, collapsing sidebars and overlay scrollbars all change the viewport, and vw / vh follow. On desktop lvh = svh = dvh, so the three only diverge on mobile (or foldables).

Keywords:viewport unitsvw vhdvhsvhlvh100vh mobile

Related tools