This page provides some idea on how the browser reports object size and position. The box to the left is a DIV that has a 400 x 300 px image as it's background. The yellow border is 15px and should exactly match the box. The box also has a 10px border.

The body margins and padding have been set to 0. This should make the box's margins the same as it's offset from the top and left of the document.

Click inside the box to see all number type properties in a popup window. Click in the paragraph to see its values in another popup.

Notice the position of this box. While its margins are 0, in Netscape this will not go higher than the box on the left. That is it will not go above the first non-floated object. Test top margin:
Add 50px Subtract 50px remove


Summed Offsets

The next set of nested boxes are provided for additional comparisons. The gray box, center1 was centered using absolute positioning inside a box with position relative.

The cyan box in the upper-left of the page will move to the position calculated by summing the the values of offsetTop and offsetLeft. To see this click a link with the word sum.

Note that IE fails to include the borders in its position calculation, where as Mozilla and its cousins does include the borders.

For nested elements, like the paragraph in the box with a 10px black border, IE measures from the inside of a border to the outside of the inner border. In this cast, from the inside of the body to the outside of the black border and then from the inside of the black border to the outside of the 1px paragraph border. It is 10px off. Your code will have to include the borders in calculating positions.

Div tag settings
width: 370px;
height: 270px;
border: 10px solid black;
margin-top: 50px;
margin-left: 60px;
padding: 15px;

P tag margin: 0; width: 100%; border 1px
Summed Offsets


Summed Offsets



DIV div-b: no styles or dimentions coded except text centered for IE.
DIV box-a

The dimentions of this box are: width: 400px, height: auto; padding: 10px.

DIV report

The dimentions of this box are: width: 200px, height: 100px; padding: 10px.

DIV pos-rel This box has position set relative; top and left are 0 and margin auto

DIV center1

This should be centered in the yellow box

dimentions 200 x 200
top and left 50%
margin top and left -100px

Yellow box is 300 x 300
So the yellow box is in its normal static position
DIV paragraphs

This link shows number properties of link

This link shows Sums for center1

This link shows sums for the containing paragraph


number properties of link without paragraph

A Small table to test
thead th
tr th
Table
tbody 1.1 td Data 1.0
d Data 2.1 tr Data 2.2
tFoot 1.1 tFoot 1.2

Here is object

Displayed Property Type