Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

positioning - when do I use relative, when absolute

Status
Not open for further replies.

rambleon

Programmer
Mar 6, 2004
130
IL
I'd like some guide lines about when to use relative and when to use absolute positioning. Seems to me absolute is better as changing the position of 1 element does'nt mean I have to change the relative position of all the following elements.
I also like to know 'relative' to what - the element to the left, right, above? How do I define a container - please
point me to a tutorial.

Thanks

Rambleon
 

Seems to me absolute is better

Well... that very much depends on what you are trying to achieve. For some things, it is better, for some, very much worse.

Absolutely positioned elements are removed from the flow of the document, in other words, they take up no space within the document, seemingly floating on top of it.

Relatively positioned elements are not removed from the flow of the document, so affect document flow, size, etc.

Regardless of which method is used, elements are positioned relative to the closest ancestor that has a position of either relative or absolute - which is not always the body / window.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top