Skip to main content
Practice

Window - window.screen

window.screen provides information about the visual setup of the user's screen.

It's mainly used when you want to know the size or resolution of the current screen or device being used.


Key Properties

  • screen.width: The full width of the screen (in pixels)

  • screen.height: The full height of the screen (in pixels)

  • screen.availWidth: The available width of the screen excluding the browser

  • screen.availHeight: The available height of the screen excluding the browser


Examples

Checking screen width and height

JavaScript
console.log(`The screen width is ${screen.width} pixels.`);
console.log(`The screen height is ${screen.height} pixels.`);

Checking available screen size

JavaScript
console.log(`The available screen width is ${screen.availWidth} pixels.`);
console.log(`The available screen height is ${screen.availHeight} pixels.`);

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.