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
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
viewport
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
See also
Viewport.segmentspropertyViewportinterfaceVisualViewportinterface- Viewport Segments API
- CSSOM view API
- Viewport concepts
- CSS viewport module
- CSSOM view module