Understanding CSS: Relative and Absolute Positioning Explained

This is a brilliantly delivered CSS video tutorial! It breaks down the difference between absolute and relative positioning in a way that really makes sense for anyone getting started with CSS.

Truly comprehending how to use the position: relative; and position: absolute; positioning declarations is necessary to have complete control over styling your documents through CSS. This is something that can be applied to just about any part of a document, which provides a high level of customization options.

When working with position: relative; the way the object in question is positioned is indeed relative to page margins of your document or relevant container. So for example, of you had a header that you wanted to be positioned in the upper left hand corner of the screen, then the code may look something like this.

h1 {
    position: relative;
    top: 5px;
    right: 5px;

Now compare that to position: absolute; where elements are positioned in relation to the browser window or parent element. So while relative positioning does not affect any other elements other than what is specifically targeted, absolute positioning can result in overlapping elements because objects are being placed in specific locations. If you wanted to position an image in the lower right corner of the screen, for instance, your code may look something like this.

img {
    position: absolute;
    bottom: 0px;
    right: 0px;

There are more ways to position things using CSS, but with these two basics fully understood you can accomplish a lot. If this simple CSS tutorial was helpful to you, you will also enjoy this post on the ‘cascading’ behavior of Cascading Style Sheets. Thanks for stopping by!

3 thoughts on “Understanding CSS: Relative and Absolute Positioning Explainedadd yours
  1. RS said: #

    Great explanation.Really helped me a lot. One thing isn’t exactly right however; In order for position:absolute to work within a container, the container doesn’t have to be position:relative. It just needs to have its position set to anything but static.

  2. krissy said: #

    Thanks a lot!. Liked your tutorial very much and it is very useful. The way you explain, stands out in memory!

  3. smix said: #

    hey, great tutorial, it was a really AHA moment like u said. u expalin it quite simple and easy, I like that.
    but i would like to know how can i adjust website to look the same for every screen resolution. would appreciate the help.

Leave a reply to krissy
this will never be published