Difference between screen.availHeight and window.height()


Javascript Problem Overview

I am executing the following Javascript on my browser (Firefox).

  1. console.debug("Screen height = "+ screen.availHeight); //outputs 770

  2. console.debug("Window Height ="+ $(window).height()); //outputs 210 (I am using jQuery as well)

What is the difference between the two? Is 770 in pixels and 210 in mm?

Similarly, when I write $(document).height() and $(window).height(), there is a difference. What is the reason?

Javascript Solutions

Solution 1 - Javascript


It's the height of the window on screen, it includes the page and all the visible browser's bars (location, status, bookmarks, window title, borders, …).

This not the same as jQuery's $(window).outerHeight().

window.innerHeight or $(window).height()

It's the height of the viewport that shows the website, just the content, no browser's bars.

document.body.clientHeight or $(document).height()

It's the height of your document shown in the viewport. If it is higher than $(window).height() you get the scrollbars to scroll the document.


It's the height the browser's window can have if it is maximized, including the browser's bars. So when the window is maximized, screen.availHeight === window.outerHeight


It simply matches the screen's resolution. So on a 1920×1080 screen, screen.height will be 1080.

screen.availHeight is equal to [screen.height + the operating system's bars], like the taskbar on Windows, the dock and menu on OS X, or whatever is fixed on top or bottom of your screen if you're using Linux.

Solution 2 - Javascript

Wanted to correct a thing stated in @jigfox 's answer:


The availHeight property returns the height of the user's screen, in pixels, minus interface features like the Windows Taskbar.

Tip: To get the height of the screen (excluding the Windows Taskbar), use the availHeight property.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAkshayView Question on Stackoverflow
Solution 1 - JavascriptjigfoxView Answer on Stackoverflow
Solution 2 - JavascriptRainCastView Answer on Stackoverflow