User Rating 0.0
Total Usage 0 times
Category CSS Tools
Real-Time Diagnostics
Viewport Width
---
px
×
Viewport Height
---
px
Device Pixel Ratio (DPR)
---
Scaling Factor
Aspect Ratio
---
---
Screen Resolution
---
Physical (Logical)
Color Depth
---
Bits per Pixel
Orientation
---
Angle: 0°
Browser Engine
---
User Agent Detection
CSS Media Query Snippet
@media (min-width: 0px) { ... }
Device Emulator Check
Select a device to compare dimensions.
Is this tool helpful?

Your feedback helps us improve.

About

In the landscape of modern web development, the distinction between physical hardware pixels and CSS logical pixels is critical. A Viewport represents the visible area of a web page, which often differs from the monitor's physical resolution due to scaling factors like the Device Pixel Ratio (DPR). Precise measurement of these values is mandatory for implementing fluid layouts and ensuring quality assurance across a fragmented device ecosystem.

This utility provides instantaneous, real-time telemetry of the browser environment. It dissects the window and screen objects to expose granular metrics: viewport geometry, color depth, orientation, and aspect ratios. Unlike basic resize listeners, this tool calculates the Greatest Common Divisor (GCD) to determine simplified aspect ratios and compares current dimensions against a verified database of industry-standard devices.

viewport screen-resolution responsive-design css-media-queries dpi-calculator

Formulas

The Aspect Ratio (R) is derived by simplifying the fraction of width (W) to height (H). This requires finding the Greatest Common Divisor (gcd).

{
gcd(a, 0) = agcd(a, b) = gcd(b, a mod b)

The simplified width component ws and height component hs are calculated as:

ws = Wgcd(W, H), hs = Hgcd(W, H)

CSS Pixels (pxcss) vs Physical Pixels (pxphys) relationship via Device Pixel Ratio (dpr):

pxphys pxcss × dpr

Reference Data

Device NameViewport (WxH)DPRScreen Size
iPhone 15 Pro Max430 × 9323.06.7″
iPhone 15 / 15 Pro393 × 8523.06.1″
iPhone 14 Plus428 × 9263.06.7″
iPhone 13 / 14390 × 8443.06.1″
iPhone SE (3rd Gen)375 × 6672.04.7″
iPad Pro 12.9″1024 × 13662.012.9″
iPad Air (5th Gen)820 × 11802.010.9″
iPad Mini (6th Gen)744 × 11332.08.3″
Samsung Galaxy S24 Ultra412 × 9153.56.8″
Samsung Galaxy S23360 × 7803.06.1″
Google Pixel 8 Pro412 × 9153.56.7″
Google Pixel 7412 × 9153.06.3″
Desktop FHD1920 × 10801.024″+
Desktop 4K UHD3840 × 21601.0+27″+
MacBook Air M21440 × 9002.013.6″
MacBook Pro 16″1728 × 11172.016.2″
Surface Pro 91440 × 9602.013″

Frequently Asked Questions

Browsers report "CSS Pixels" (Logical Resolution), not physical hardware pixels. High-DPI (Retina) screens use a scaling factor called Device Pixel Ratio (DPR). For example, a 4K screen (3840 physical pixels) with a 200% scale (DPR 2) will report a viewport width of 1920 CSS pixels.
The generated snippet is a standard CSS conditional rule. Copy the block into your CSS file. The `min-width` query applies styles only when the browser is at least as wide as your current viewport, while `max-width` limits styles to sizes smaller than the current state.
No. The Web API security model prevents browsers from accessing physical screen dimensions (e.g., "24 inches") to prevent user fingerprinting. We can only access the resolution in pixels and the color depth.
`window.innerWidth` is the width of the viewport (the web page content area), which changes when you resize the browser window. `screen.width` is the total width of your monitor's display area and remains constant regardless of the browser window size.