views:

78

answers:

2

What is the difference between relative and absolute tags of div element ?

+1  A: 

If you specify position:relative, then you can use top or bottom, and left or right to move the element relative to where it would normally occur in the document. The div stays within the flow of the document, but just moves relative to the position that it is specified at within the document.

When you specify position:absolute, the element is removed from the document and placed exactly where you tell it to go. It's not relative to the place you where the div actually occurs in the document.

Gavin
+3  A: 

Absolute positioning positions an element relitive to the first parent that has a position oher than static, and removes the element from the document flow. Relative positioning allows you to move an element from its "normal" positon, leaving the space where it was originally in the content.

Relative is generally for small adjusents in page layout, absolute is for exact positioning.

crazy2be