Difference between Absolute and Relative

Difference between Absolute and Relative
0.0 0

#1

Can someone please explain to me the difference between absolute and relative (used i css)


#2

I believe absolute is positioned based on the nearest parent element that is absolute or relative. So an element with an absolute position of 5px top and 5px left will be placed 5px from the top and left of it’s parent, assuming its position is relative or absolute. Relative however is positioned relative to where it would normally be on the site. So a relative 5 px top 5px left will be moved 5 from the top and left of where it would normally be.

The MDN docs on position have a great demo.
https://developer.mozilla.org/en-US/docs/Web/CSS/position


#3

Thank you very much for your response.