Table of Contents
The screen.width property returns the width of the visitor's screen in pixels:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Window Screen</h2>
<p>From w3schools.com, Experiment by Teeratus_R</p>
<h4>Window Screen Width</h4>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Screen width: " + screen.width + "px";
</script>
</body>
</html>

Result View Example
The screen.height property returns the height of the visitor's screen in pixels:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Window Screen</h2>
<p>From w3schools.com, Experiment by Teeratus_R</p>
<h4>Window Screen Height</h4>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Screen height: " + screen.height + "px";
</script>
</body>
</html>

Result View Example
The screen.availWidth property returns the width of the visitor's screen in pixels, minus interface features like the taskbar:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Window Screen</h2>
<p>From w3schools.com, Experiment by Teeratus_R</p>
<h4>Window Screen Available Width</h4>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Available screen width: " + screen.availWidth + "px";
</script>
</body>
</html>

Result View Example
The screen.availHeight property returns the height of the visitor's screen in pixels, minus interface features like the taskbar:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Window Screen</h2>
<p>From w3schools.com, Experiment by Teeratus_R</p>
<h4>Window Screen Available Height</h4>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Available screen height: " + screen.availHeight + "px";
</script>
</body>
</html>

Result View Example
The screen.colorDepth property returns the number of bits used to display one color. The screen.pixelDepth property returns the pixel depth of the screen:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Window Screen</h2>
<p>From w3schools.com, Experiment by Teeratus_R</p>
<h4>Window Screen Color and Pixel Depth</h4>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Screen color depth: " + screen.colorDepth + " bits<br>" +
"Screen pixel depth: " + screen.pixelDepth + " bits<br><br>" +
"All screen properties:<br>" +
"Total size: " + screen.width + " x " + screen.height + "<br>" +
"Available: " + screen.availWidth + " x " + screen.availHeight + "<br>" +
"Color depth: " + screen.colorDepth + " bits<br>" +
"Pixel depth: " + screen.pixelDepth + " bits";
</script>
</body>
</html>

Result View Example
Document in project
You can Download PDF file.