The innerWidth property in JavaScript returns the width and innerHeight property returns the height of window content area.
Syntax:
window.innerWidth window.innerHeight
Parameter: It doesn’t required any parameters.
Return Value: It Returns a number, Representing the Width and Height of the window’s content area.
Note: For IE 8 i.e (Internet Edg 8) or earlier, use clientWidth and clientHeight to get width and height of window.
Example:
<!DOCTYPE html> <html> <head> <title>Browser Inner width and height</title> <style> body{ text-align:center; } .gfg { font-size:40px; font-weight:bold; color:green; } </style> </head> <body> <div class = "gfg">GeeksforGeeks</div> <h2>Browser Window</h2> <p id="demo"></p> <script> var Width, Height, result; // height and width of Browser window Width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; Height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // Display Width and Height. result = document.getElementById("demo"); result.innerHTML = "Browser inner width: " + Width + "<br>Browser inner height: " + Height; </script> </body> </html> |
Output:

Recommended Posts:
- HTML | Window innerHeight Property
- HTML | Window innerWidth Property
- Javascript | Window Open() & Window Close Method
- Javascript | Window Blur() and Window Focus() Method
- JavaScript BOM | Window Screen
- Javascript | Window confirm() Method
- Javascript | Window prompt() Method
- Javascript | Window scrollTo() Method
- JavaScript | Window print() Method
- jQuery | innerWidth() with Example
- jQuery | height() and innerHeight() with Examples
- Transition shorthand with multiple properties in CSS?
- HTML | Window self( ) Property
- HTML | Window top( ) Property
- HTML | Window name Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



