Difference between absolute and relative positioning

There are two types of positioning: absolute and relative. Absolute positioning will place an element absolutely on your page. You can specify the exact pixel location. If you want to place an image to appear 50 pixels from then top of the page and 50 pixels from the right, you can do this:

img { position: absolute; top 50px; right 50px; }

While relative means you are positioning it from the normal position. You can use it to draw x2. The letter x in this case is the normal position and you are positioning the power 2 relative to the letter x. The code is:

position: relative; bottom:4px; left: 1px;

You should remember that if you want to move something right, you use the right code, and vice versa.

Related posts:

  1. How to protect your images being taken
  2. Adsense channel
  3. How to create a high-conversion sales letter?

2 comment(s)

  • Nov 4, 2009 by Tejas from PSD to HTML

    There is also Fixed Positioning which is defined in W3Schools as
    The element with fixed position is positioned relative to the browser window.
    It will not move even if the window is scrolled

  • Jul 29, 2010 by Rowena from Extra Long Twin Bed

    Well, What do you mean by “normal position”? Is it the way how the page and your contents move when the user resize or move the browser window itself? If it goes with the browser or if it adjust itself so that it will perfectly fit on the browser window, that is quite good and that should be the format you should be using.

  • Any feedback from you?

    This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

Nov 6, 2008 by

Want to set up your own web server at home? Read this guide

Super Green Hosting HostGator GreenGeeks WP Web Host green web hosting ad