What is viewport in HTML.

The viewport is the part of the webpage that the user can currently see. The scrollbars move the viewport to show other parts of the page.

Follow this article's instructions to get the viewport dimensions in Javascript.

if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

I think the ViewPort is just an area to display the web content in the browser. And different browsers have their own setting for the size of ViewPort, For example, the default ViewPort width of Safari is 980 pixels. So, if the actual web page you want to see is smaller than 980 pixels, there should be a blank display area in the Safari when accessing the web page in the Safari by default. Hence, that is the reason sometimes we need to configure the ViewPort for better web content display in the browser.

Like below, for example:

<meta name="viewport" content="width=device-width">

And also please read Paul's answer. I think he already explained the usage of ViewPort.