Window innerWidth
Example
Get window width:
let width = window.innerWidth;
Try it Yourself »
let width = innerWidth;
Try it Yourself »
More examples below.
Definition and Usage
The innerWidth
property returns the width of a window's content area.
The innerWidth
property is read-only.
Syntax
window.innerWidth
or just:
innerWidth
Return Value
Type | Description |
A number | The the inner width of the browser window's content area in pixels. |
More Examples
All height and width properties:
let text =
"<p>innerWidth: " + window.innerWidth + "</p>" +
"<p>innerHeight: " + window.innerHeight + "</p>" +
"<p>outerWidth: " + window.outerWidth + "</p>" +
"<p>outerHeight: " + window.outerHeight + "</p>";
Try it Yourself »
Browser Support
window.innerWidth
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |