Favorites

DOM Window.innerWidth Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Window.innerWidth
DOM Window PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The innerWidth property returns the width of the browser's viewport in pixels. innerHeight returns its height.

Description

The read-only innerWidth and innerHeight properties give the size of the viewport, the visible area of the page, in CSS pixels, including a vertical or horizontal scroll bar if there is one. document.documentElement.clientWidth gives the width without the scroll bar. To react to breakpoints, matchMedia() is usually a better fit than checking these values.

On mobile devices, the values reflect the layout viewport, which depends on the <meta name="viewport"> tag and can change when the on-screen keyboard appears or the browser's toolbars hide. The visualViewport object gives the size of the area actually visible after pinch-zooming.

Reading the size inside a resize handler is the traditional way to respond to window changes, but for layout, CSS media queries and container queries usually do the job without any JavaScript.

Syntax

window.innerWidth
window.innerHeight

Value

The width (or height) of the viewport in CSS pixels, including any scroll bar.

Example

console.log(window.innerWidth + ' x ' + window.innerHeight);
console.log(document.documentElement.clientWidth);

Browser Support

The following information will show you the current browser support for the Window.innerWidth property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee