Absolute vs relative positioning

Understanding relative and absolute positioning in CSS didn’t come easily to me when I first started building websites.Now ages after building more websites than I count.I have gotten used to way the browser positions stuff.

Before I talk about absolute/relative position I need to explain what static position is.

0


 

By default every element in the DOM is positioned static.Which means every element appears one after the other in the order they were written in the body tag.

So what is absolute position?Absolute position is where you set the position of the current element relative to the firstĀ parentĀ element.

0


Relative position on the other hand sets the element relative to the parent.

0

So we can build awesome stuff by combining the two.

0