width: 16.6667vw; /* 320px */
What Are vw and vh Units?
vw (viewport width) and vh (viewport height) are relative CSS units calculated against the browser window. 1vw = 1% of the viewport width; 1vh = 1% of the viewport height. Unlike % (relative to parent) or rem (relative to root font-size), viewport units are always relative to the browser window — making them perfect for hero sections, full-bleed images, fluid typography, and responsive layouts that need to scale with screen size regardless of container nesting.
px to vw / vh Converter Online — What This Tool Does
This free px to vw converter performs bidirectional conversion in your browser. Enter a pixel value and your target viewport width (or height) to see the vw / vh equivalent, with a live visual preview showing the computed pixel size.
How to Convert px to vw
- Enter a pixel value in the px field.
- Set the Viewport Width to your target screen width (default 1920px for desktop). For mobile-first design, try 375px (iPhone) or 412px (typical Android).
- Toggle VW / VH to switch between width-based and height-based conversion.
- The vw equivalent appears instantly:
px / viewport × 100. - The visual preview shows the computed pixel width.
vw vs % — Key Differences
- vw — always relative to viewport (browser window). Survives nesting.
- % — relative to immediate parent. Changes meaning at every nesting level.
- Use vw for hero sizing, full-bleed elements, and fluid typography that should scale with screen size.
- Use % for components that should fill their container regardless of viewport.
Mobile Viewport Caveats
- vh changes on mobile — when the address bar shrinks during scrolling, the viewport grows, and 100vh elements jump. Use
100dvh(dynamic viewport height) on modern browsers to avoid this. - svh / lvh / dvh — small/large/dynamic viewport units (CSS Values Level 4) give more precise control on mobile.
100svh= smallest viewport height (with browser chrome visible). - Test in landscape — vw / vh values that look right in portrait can break dramatically in landscape orientation.
- Don't use vw for typography alone — use
clamp()to set min/max bounds:font-size: clamp(1rem, 2vw, 1.5rem)avoids tiny text on phones and huge text on 4K monitors.
Tips & Tricks
- Fluid typography with clamp() — combines rem floor + vw scaling + rem ceiling for typography that adapts cleanly across all screen sizes.
- Pair vw with max-width —
width: 90vw; max-width: 1200pxfor centred, capped containers. - Use 100dvh for full-height sections on mobile — avoids the jumpy address-bar bug.
- For container queries — when you need sizing relative to a parent's actual rendered width (not viewport), use CSS container queries with
cqw/cqhinstead of vw / vh.
Related Tools
- px ↔ rem Converter — typography and design-system sizing.
- px ↔ em Converter — component-scoped sizing.
- px ↔ % Converter — fluid layout sizing relative to parent.
- rem ↔ em Converter — translate between the two relative font units.
- Color Picker — pick brand colours for your design system.
Is My Data Sent to a Server?
No. All unit conversion runs entirely in your browser using simple JavaScript math. The values you enter — including any proprietary design-system tokens — never leave your device. There is no upload, no logging, and no analytics on the numbers you enter.