Difference between Absolute and Relative

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

1 Like

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

1 Like

Thank you very much for your response.