The window.screen object contains information about the physical monitor display on which the current browser window is rendering. It provides monitor width, height, available working area, and screen orientation.
flowchart TD
ScreenArea["Full Monitor Screen (screen.width x screen.height)"] --> Taskbar["OS Taskbar / Menu Bar Space"]
ScreenArea --> AvailArea["Available Display Area (screen.availWidth x screen.availHeight)"]
| Property | Return Value | Description |
|---|---|---|
screen.width |
Number (Pixels) | Total physical width of monitor display. |
screen.height |
Number (Pixels) | Total physical height of monitor display. |
screen.availWidth |
Number (Pixels) | Available display width (excludes OS taskbars/docks). |
screen.availHeight |
Number (Pixels) | Available display height (excludes OS taskbars/docks). |
screen.colorDepth |
Number (Bits) | Bit depth of color palette (e.g. 24 or 32 bit). |
screen.orientation |
ScreenOrientation |
Returns orientation type ("portrait-primary", "landscape-primary"). |
// Demonstrating window.screen metrics inspection
console.log("--- Physical Display Metrics ---");
console.log(`Screen Resolution: ${screen.width} x ${screen.height} px`);
console.log(`Available Area (excluding OS taskbar): ${screen.availWidth} x ${screen.availHeight} px`);
console.log(`Color Depth: ${screen.colorDepth}-bit`);
// Screen Orientation API
if (screen.orientation) {
console.log(`Screen Orientation Type: ${screen.orientation.type}`); // e.g. "landscape-primary"
screen.orientation.addEventListener("change", () => {
console.log(`New Screen Orientation: ${screen.orientation.type}`);
});
}
screen.width for Responsive CSS Layouts: Never use screen.width to make responsive CSS layout decisions. Always use viewport width window.innerWidth or CSS @media (max-width: ...) queries.screen properties reflect metrics of the specific monitor displaying the active browser window.Why should responsive design breakpoints be based on window.innerWidth instead of screen.width?
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.