Skip to content
Related Articles

Related Articles

JavaScript | Window innerWidth and innerHeight Properties

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 14 Feb, 2019

The innerWidth property in JavaScript returns the width and innerHeight property returns the height of window content area.



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.


<!DOCTYPE html>
          <title>Browser Inner width and height</title>
            .gfg {
     <div class = "gfg">GeeksforGeeks</div>
     <h2>Browser Window</h2>
     <p id="demo"></p>
          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;


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!