Window screen.width Property
- Previous Page pixelDepth
- Next Page availHeight
- Go to the Previous Level Window Screen
Definition and usage
width
The property returns the total width of the user's screen.
width
The property returns the width in pixels.
width
The property is read-only.
Tip:Please use height attribute Get the total height of the user's screen.
Example
Example 1
Get the total width of the screen:
let width = screen.width;
Example 2
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;
Syntax
screen.width
Return value
Type | Description |
---|---|
Number | The total width of the user's screen (in pixels). |
Browser support
All browsers support screen.width
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related pages
- Previous Page pixelDepth
- Next Page availHeight
- Go to the Previous Level Window Screen