Window: viewport property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The viewport read-only property of the Window interface returns a Viewport object instance, which provides information about the current state of the device's viewport.

See the Viewport API for all available properties.

Value

A Viewport object instance.

Examples

Basic viewport usage

js
const currentViewport = window.viewport;
const segments = window.viewport.segments;

Specifications

Specification
CSS Viewport Module Level 1
# dom-window-viewport

Browser compatibility

See also