Home JavaScript Screen JavaScript Screen Definition
Definition and Usage The screen object (window.screen) describes the userโs display: width, height, available space, and color depth.
Use screen.width / screen.height for the full screen size, and availWidth / availHeight for the space minus system UI. Orientation APIs and the change event help when the device rotates.
This page teaches what Screen is. Events, methods, and properties live under this section.
Screen size โ viewport size. For layout inside the browser window, prefer window.innerWidth. screen.width is the whole monitor.
Syntax
JavaScript Syntax Reading Screen properties:
console.log(screen.width, screen.height);
console.log(screen.availWidth, screen.availHeight);
console.log(screen.colorDepth); Reference
Core Ideas Ideas every Screen tutorial builds on:
Idea Example Remember Full size screen.widthEntire display width Available screen.availWidthMinus taskbars / docks Color screen.colorDepthBits per pixel Orientation screen.orientationPortrait / landscape API change screen.addEventListener("change")Display configuration changes vs viewport window.innerWidthUse for CSS-like layout
Code
JavaScript Examples Three short programs that show how Screen works.
1. Size 2. avail 3. colorDepth Example 1 — Log screen dimensions width and height are the full screen in CSS pixels.
console.log(screen.width > 0);
console.log(screen.height > 0); How It Works screen.width is a positive number on real devices.screen.height is the matching height.Values are for the display, not the browser window. Example 2 — Available size avail* excludes some system UI chrome.
console.log(screen.availWidth <= screen.width);
console.log(screen.availHeight <= screen.height); How It Works availWidth is never larger than width.availHeight is never larger than height.Useful when placing pop-up windows. Example 3 — Color depth colorDepth is typically 24 or 30 on modern screens.
console.log(typeof screen.colorDepth);
console.log(screen.colorDepth >= 24); How It Works colorDepth is a number of bits.Most displays report at least 24. Rarely needed for everyday UI work. Continue
Next: Screen Guides Continue with the change event and screen properties.
Look up Why change Listen for display changes width / heightFull screen size availWidthSpace minus system UI orientationPortrait / landscape details
Full lists: Screen change event .
Frequently Asked Questions What is screen in JavaScript? window.screen is an object that describes the display: its pixel size, available area, color depth, and orientation-related features.
Should I use screen.width for responsive layout? Usually no. Use CSS media queries or window.innerWidth for the browser viewport. screen.width is the whole monitor.
What is availWidth? It is the horizontal space available roughly outside OS taskbars and docks. It is less than or equal to screen.width.
Does screen work in Node.js? No. Screen is a browser API. It is undefined in typical Node.js scripts.
Where should I go next? Open the change event guide, then Window for viewport sizes.
Open the Screen change event Then browse width, availWidth, and orientation properties.
change event → CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion