# How to get the Width and Height of the screen in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

Javascript has provided window.screen object that contains information regarding the user's screen. The information includes height and width, and also many other features. To find the height and width of the screen the methods provided by javascript are screen.height and screen.width respectively.

## Height-syntax

scree.height;

## Width-syntax

scree.width;

## Example

In the following example, the width of the screen is displayed using the screen.width method.

Live Demo

<html>
<body>
<p id="width"> </p>
<script>
document.getElementById("width").innerHTML =
"Screen width is " + screen.width;
</script>
</body>
</html>

## Output

1366

## Example

In the following example, the height of the screen is displayed using the screen.height method.

Live Demo

<html>
<body>
<p id="height"> </p>
<script>
document.getElementById("height").innerHTML =
"Screen heigth is " + screen.height;
</script>
</body>
</html>

## Output

768
Published on 15-Jul-2019 12:41:25