Window screen.width
Example
Get the total width of your screen:
let width = screen.width;
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The width
property returns the total width of the user's screen.
The width
property returns width in pixels.
The width
property is read-only.
Note
Use the height property to get the total height of the user's screen.
Syntax
screen.width
Return Value
Type | Description |
A number | The total width of the user's screen in pixels. |
More Examples
All screen properties:
let text = "Total width/height: " + screen.width + "*" + screen.height + "<br>" +
"Available width/height: " + screen.availWidth + "*" + screen.availHeight + "<br>" +
"Color depth: " + screen.colorDepth + "<br>" +
"Color resolution: " + screen.pixelDepth;
Try it Yourself »
Browser Support
screen.width
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |