Explaining the differences between the CSS properties: static, absolute, fixed, and relative
Nichole Shelton
November 9, 2014
For the blog post I'll be describing the differences between absolute, fixed, relative, and static properties in CSS. I was stumped by this a few times, so nothing works better to understand a concept than to teach it right?
Let's start with Static.
Static: This is the default of all elements. The element will be on the page where it is placed in the html. Look at the example below. Static is the last element on the html page flow. It's lives on the bottom of the page.
Next up is Absolute
Absolute: This value allows the element to move with the page. Using the absolute position takes the element out of the HTML page flow. It reacts to the properties TOP, BOTTOM, LEFT, AND RIGHT. Take a look at the example below. I'm placing the element at LEFT: 0px, BOTTOM: 0px and position absolute. Notice the absolute element is green. Also take note, absolute comes FIRST in the HTML page flow.
Let's discuss our friend Relative.
O dear friend relative. This one I've grappled with. The simples answer I can provide is, when you use the property relative, you are moving the element relative to ITSELF. Relative to where it would have already been on the page. The elements shifts in the OPPOSITE direction of the properties TOP, LEFT, BOTTOM, AND RIGHT. The relative element is purple. Please take note that relative is at the top right of the page. We are going to move it BOTTOM: 10px and LEFT: 10px. In other words, we are going to move the purple box up 10 pixels and to the right 10 pixels. Let's watch our video.
Let's talk about our last property Fixed.
Fixed position does just what it says. It fixes itself wherever you decide to put it. It stays exactly where it is when you're scrolling up and down. Our red fixed element is located at the top of the page at LEFT: 400px. Watch as I scroll and it fixes itself on the page.

