The Viewport, the Page Box, and the Canvas

In a continuous output medium, such as a computer monitor, a browser displays a web document in a viewport—a rectangular window through which we can view a part of the document. In a paged medium, such as printed paper, each page can be seen as a viewport whose dimensions are the same as the page box (the printable part of the page, excluding any page margins).

The browser renders the document on a canvas, which, consequently, is at least as large as the document itself. If the viewport is larger than the document, the canvas fills the viewport.

Any background color or image that’s specified for the root element—the html element for HTML and XHTML documents—will be rendered as the background for the whole canvas, rather than for the root element alone.1 In other words, the background specified for the root element will cover the entire content area of the browser window, even if the document doesn’t contain enough content to fill the whole window.

Footnotes

1 This is not the case in Internet Explorer 5.5 and prior versions, where if a background is specified for the body element, it will cover the whole canvas and obscure any background that’s specified for the html element.

User-contributed notes

Related Products