Absolute vs. Relative Positioning

When should I use absolute positioning?

Use absolute position whenever you want to position something at an exact X and Y locaction within a block level element with a fixed height (ie. a header), and so long as it is ok that the element that you are positioning can break normal flow (ie. so long as other elements are not depending upon it, or that it is not pushing some other elements - stacked below it - down), then it is OK to use absolute positioning.

Only use absolute positioning when absolutely necessary, and always use it with caution, paying particularly close attention to the normal flow of the document.

When should I use relative positioning?

Only use relative positioning on an element when you want to position other elements inside of it, and you want it to be its parent (a new X,Y of 0,0). DO NOT use relative positioning on an element to position itself.

In other words, use relative position sparingly, usually to set the "parent" of nested elements inside of it. For example, one common use of relative positioning is for a "container" div, so that all of the elements inside of it are centered/positioned according to its X,Y of 0,0 (the container's top left corner). Another example: a common practive is to have a fixed height header (ie 200px), and then position the logo absolutely where you want it, using absloutely positioning. Normal flow is broken only within the relative div, but it is returned/corrected by the fixed height.

This is random content below the absolutely positioned div.

Note how this content is not being pushed down by the absolutely positioned element above. This is because normal flow has been broken by absolute positioning. The result is overlapping elements, with the elements below sliding up behind the absolutely positioned elements.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?