Before I can start with the explanation of 'position' I have to squeeze in another little section. You will need to know 4 other properties, to work properly with 'position'.
left, right, top, bottom. As with the 'height' and 'witdth' properties explained earlier, they work with the absolute unit px (pixel) and the relative units (em, font size; and %, percent relative to the parent element).
Back to 'position': So far, we still are not able to tell elements where to sit in a page, or containing block element. We can make things flow but that is not enough. For specific positioning one has to use the property 'position', with one of those values:
. There is no distance to the
text above, and there are no elements overlapping, everything flows normally. Since I did not
add any line break, the images just are part of the normal text lines. Now we add the
picture a second time, but with top:30px and left:30px:
. Now you can
see there's a gap above that picture, and the picture is partially in the text of the following line.
But it's still part of the normal flow, still inside the text line, and still pushing that text line to
a huge line-height.
position:fixed; top:200px; left:20px;), but with relative units: 20% to the left, 20% from the top.
Still, absolute positioning is a bit tricky because you never know in what environment your page will be viewed.
top:-10px; position:relative;