English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Screen width property

JavaScript Screen Object

widthA read-only property that returns the total width of the screen (in pixels).

UsageheightProperty to get the total height of the screen (in pixels).

Syntax:

screen.width
var x = "Total Width: " + screen.width;
Test and see‹/›

Browser compatibility

All browsers fully support the width property:

property
widthisisisisis

Technical details

Return value:A number representing the total width of the user's screen, in pixels

More Examples

This example displays all screen properties:

var txt = "";
txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight +"</p>";
txt += "<p>Color depth: " + screen.colorDepth + "</p>";
txt += "<p>Color resolution: " + screen.pixelDepth + "</p>";
document.write(txt);
Test and see‹/›

Related References

screen reference:screen.availHeight property

screen reference:screen.availWidth property

screen reference:screen.colorDepth property

screen reference:screen.height property

screen reference:screen.pixelDepth property

JavaScript Screen Object