Absolute Positioning

Using absolute position allows you to place an image, box or text exactly where you want it by changing the values from the top and left of the browser window.

The code below puts an image 100 pixels from the top and 100 pixels from the left.

<IMG STYLE="position:absolute; top:100px; LEFT:100px" src="images/magpie.jpg" width="123" height="78" border="0">

View Here

The code below puts two images 100 pixels from the top, the first image is 100 pixels from the left the second image is 500 pixels from the left.

<IMG STYLE="position:absolute; top:100px; LEFT:100px" src="images/magpie.jpg" width="123" height="78" border="0"><IMG STYLE="position:absolute; top:100px; LEFT:500px" src="images/magpie.jpg" width="123" height="78" border="0">

View Here

The code below puts two images 100 pixels from the top, the first image is 100 pixels from the left the second image is 600 pixels from the left with text placed between the two images.

<IMG STYLE="position:absolute; top:100px; LEFT:100px" src="images/magpie.jpg" width="123" height="78" border="0"><IMG STYLE="position:absolute; top:100px; LEFT:600px" src="images/magpie.jpg" width="123" height="78" border="0" <DIV style="position: absolute; top:100px; left:320px; width:165px; font-size: 2em; background-color:#CDA7F4; border:#333333 1px solid; padding:10px">CSS Magpie</DIV>

View Here

Relative Positioning

I think one of the easiest explanations of relative and absolute positioning is from echoecho.com and this is it.

If you define the position to be relative it will be relative to the position of the tag that carries the style. That is, if you add a relatively positioned layer in the middle of the page, then the position will be calculated from that exact spot in the middle of your page where it was added.

Still a bit tricky to understand eh. Well enough of the words look at the images below and all will become clear I hope.

absolute positioningrelative positioning

Both images have been placed 50 pixels from the top and 50 pixels from the left, they have also had two line breaks (<br />) placed before the style code.

The image on the left is set at "position absolute" and will stay in that position regardless, whereas the image on the right which is "position relative" is governed by its surroundings (in this case two line breaks) so the image now moves 50 pixels below the line breaks giving it the relative position.

This link shows position relative when there is nothing to effect it.