Skip to content

JavaScript innerWidth | Property

  • by

Use JavaScript innerWidth window Property to get the width of a window’s content area. This method returns the width of the window in pixels and includes the width of the vertical scroll bar if one is present.

window.innerWidth
//OR
innerWidth

Note: The innerWidth property is read-only.

JavaScript innerWidth example

Simple example code.

<!DOCTYPE html>
<html>
<body>
  <script>
    let height = window.innerWidth;
    //OR
    let h = innerWidth;
    
    console.log('Window Width ',height)
    console.log('Width',h)
  </script>

</body>
</html>

Output:

JavaScript innerWidth Property

This property is particularly useful for creating responsive designs or performing calculations based on the available space within the browser window.

Do comment if you have any doubts or suggestions on this JS Property topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading