This subject is so esoteric that even I myself don't quite know what I'm searching for. I hope that it becomes clearer after I've added new experiments.
This area of web development hasn't been standardized at all; in fact W3C seems to back away from the viewport as an aberration in its orderly realm of structural (semantic!) data and device independence.
W3C's Level 2 DOM Views specification is laughable. Its Level 3 DOM Views and Formatting draft is not much better. None of the more or less cross-browser properties dealing with the viewport appear in it. Fortunately it is no longer part of the DOM specification.
The CSS 2.1 specification is clearer, but still has some holes in it.
body. Thus the
bodyis the containing block of the
div. So far so good.
htmlelement? For the moment I'm going to assume so.
htmlelement as the initial containing block, or inserting yet another block between it and the viewport.
In my view, if W3C seriously wishes to standardize viewport and friends (which in itself wouldn't be a bad idea), it should
So browsers have been left to themselves. In the past this would have been a sure recipe for disaster, but nodwadays browser vendors pay attention to each other's implementations, which makes the situation less bad than it could have been.
In the past there were a Netscape and a Microsoft system for reading out, say, the width and height of the browser window. These systems have largely survived, and the Microsoft one has been greatly extended. Mozilla, Opera and Safari now support both systems.
These systems are detailed on the Browser compatibility page.
I'm pretty sure about the DIV, BODY and HTML layers, but the higher layers are vaguer.
but it's not as easy as you'd think. For instance, there are only a few
that actually say something about the viewport, and they're not cross browser.
For more serious information about the viewport we have to go to the
document.documentElement objects, which are supposed to reflect another layer of the HTML/CSS
document. This is for historical reasons only: Microsoft defined
as the height of the viewport, and all other browsers followed.
document object has no HTML/CSS counterpart at all.
As you see this is all still quite vague. I hope to significantly update my theory later on, but that'll have to wait until I know what I should test for.
I have devised a few experiments to make the relations between these objects clearer. The real problem is finding out which experiments I should perform and what they prove (or don't prove).
You can find them at my experiments page.