PX to REM & EM Converter – Scalable CSS Units
Convert pixel values to rem or em based on the root font size. Also batch‑convert an entire CSS snippet, replacing px with rem for accessibility.
UD5 Toolkit
Convert pixels to responsive viewport units instantly. Free online calculator for front-end developers.
VW (Viewport Width) and VH (Viewport Height) are CSS length units that represent a percentage of the browser's viewport dimensions. 1vw = 1% of the viewport width, and 1vh = 1% of the viewport height. These units are part of the CSS Values and Units Module Level 3 specification and are widely supported across all modern browsers. They enable truly responsive designs that adapt fluidly to any screen size without relying on media queries.
The formula is: VW = (PX value / Viewport Width in px) × 100
For example, if your design is based on a 375px viewport width (like iPhone 6/7/8) and you want to convert 100px:
VW = (100 / 375) × 100 = 26.67vw
This means 100px is approximately 26.67% of a 375px-wide viewport. Use this calculator above for instant, accurate conversions.
The formula is: VH = (PX value / Viewport Height in px) × 100
For example, with a 667px viewport height and 100px:
VH = (100 / 667) × 100 = 14.99vh
VH is especially useful for full-screen sections, hero areas, and elements that need to scale with the viewport height on mobile devices.
Use VW/VH when you need:
Use PX for elements that need precise, fixed sizing like icons, border widths, or when pixel-perfect control is required.
Yes! VW and VH have excellent browser support (97%+ globally). They are supported in:
There are newer variants like dvh (dynamic viewport height) and svh (small viewport height) for handling mobile browser address bars, but classic VH remains fully supported.
Percentages (%) are relative to the parent element's dimensions, while VW/VH are always relative to the viewport (browser window). This is a crucial distinction:
width: 50% → 50% of the parent container's widthwidth: 50vw → 50% of the entire browser window widthVW/VH bypass the DOM hierarchy, making them ideal for top-level layout elements that need to ignore nested container constraints.
Absolutely! Using VW for font sizes enables fluid typography. A common technique is:
font-size: calc(16px + 0.5vw);
This creates a base font size that grows smoothly with the viewport. Many designers use the clamp() function for even better control:
font-size: clamp(1rem, 0.8rem + 1vw, 2.5rem);
This sets a minimum, fluid, and maximum font size — perfect for responsive headings.
Common viewport width breakpoints used in responsive design:
When converting PX to VW, knowing your design's target viewport is essential for accurate results.
This is a known challenge! On mobile browsers (especially Safari on iOS and Chrome on Android), the address bar collapses as users scroll, changing the effective viewport height. Traditional VH includes the address bar area, which can cause layout shifts.
Newer CSS units address this:
For production, consider using 100dvh for full-screen mobile layouts, with a fallback to 100vh for older browsers.
The reverse formula is: PX = (VW value × Viewport Width in px) / 100
For example, if you have 5vw on a 1440px wide screen:
PX = (5 × 1440) / 100 = 72px
This is useful when you need to determine the actual pixel size a VW-based element will render at on a specific screen. Use the reverse converter in this tool for quick calculations.
Convert pixel values to rem or em based on the root font size. Also batch‑convert an entire CSS snippet, replacing px with rem for accessibility.
Design a responsive navigation bar with a pure CSS hamburger menu. Customize colors and breakpoints. Copy the code.
Upload one image at multiple widths and generate the complete img srcset and sizes attributes. Perfect for performance.
Enter a URL and view it in three iframes: mobile, tablet, and desktop side‑by‑side. Quick responsive check.
Change the viewport meta tag and see how a page would render at different device widths. Understand responsive basics.
Enter a URL and generate a responsive iframe embed code with correct aspect ratio. Supports YouTube, maps, and more.
Write a media query and see if it matches as you resize the iframe. Understand width, height, and resolution queries.
See outerWidth, innerWidth, outerHeight, innerHeight, screenX/Y, and availWidth/Height live. Understand the viewport.
See the current viewport width/height, document size, scrollbar width, and pixel ratio. Essential responsive data.
See your website inside iframes at multiple breakpoints simultaneously. Side‑by‑side responsive testing.
Build a CSS media query by selecting feature, operator, and value. Copy the exact syntax for your stylesheet.
Combine aspect‑ratio with min‑/max‑width/height and see how the box responds. Understand sizing constraints. Copy the pattern.
Enter min and max font sizes and viewport widths to generate a perfect CSS clamp() expression. Fluid typography without media queries.
Upload multiple sizes of the same image and generate the complete srcset and sizes attributes. For perfect responsive performance.
Experiment with CSS container queries in a live editor. Resize the container and see styles change based on its width/height. Learn modern responsive.
Convert pixel values to viewport‑relative units (vw, vh, vmax, vmin) for a specified breakpoint. Includes DVH and SVH. Essential for fluid layouts.
Upload an image at multiple widths and generate a complete <picture> or <img srcset> snippet. Modern web performance.
Create CSS clamp() values for fluid typography. Enter min and max font sizes and viewport widths. Modern responsive design.
Build a proper <meta name='viewport'> tag with width, initial‑scale, and user‑scalable options. Avoid common mobile rendering issues.
Paste any iframe embed code (YouTube, maps) and get a responsive wrapper div with correct aspect ratio CSS.
Write a media query and instantly see if it matches your current viewport. Width, height, orientation, and more.
See exact dimensions of your current browser inner/outer window, screen resolution, and pixel ratio. Developer debug.
Convert REM values to pixels and vice versa based on your root font size. Essential for scalable web typography.
Enter a URL and drag a slider to change the viewport width smoothly. See exactly where your layout breaks. No iframe limits.
Preview any website inside emulated device viewports (iPhone, iPad, various resolutions). No screenshot, live interaction in an iframe. Local tool.
Detect your current screen resolution, viewport dimensions, and device pixel ratio. Useful for responsive design testing. No data collection.