Go to Lesson #4: ColorsGo to lesson #6: Working With ImagesAddressing

Before we go any further, it will be useful to take a minute to understand the difference between absolute and relative addressing.

Let's begin with a typical URL (see an article title "URLs" for more information about URLs in general).

http://www.html-helper.net/tutorial/images/t.gif

This is known as absolute addressing. You are specifically and totally representing exactly which URL you desire. This kind of addressing is most useful for referencing things which are outside of your web site.

You will also use absolute addressing to reference files stored on FTP sites. 

However, this kind of addressing should not be used to references files and objects within your own web site. To do that you need to use relative addressing.

Let's start simple.

http://www.html-helper.net/tutorial/page1.htm
http://www.html-helper.net/tutorial/page2.htm

If "page1.htm" needs to reference "page2.htm", it would look like this:

page2.htm

You see, we leave off the "http://www.html-helper.net/tutorial/" because the web server is smart enough to understand that if none of that is present then the file is in the current ("/tutorial/") directory.

Let suppose you have the following two URLs.

http://www.html-helper.net/tutorial/page1.htm
http://www.html-helper.net/forms/myform.htm

Okay, now the file "myform.htm" needs to make a reference to the file page1.htm. How do you do that?

../tutorial/page1.htm

Huh? That sure looks strange, doesn't it?

What this means is "go up one directory (that's the http://www.html-helper.net/) and then go to the "/tutorial/" directory and get the file "page1.htm".

Let's do a little more complicated example.

http://www.html-helper.net/browsers/forms/samples/tt.htm
http://www.html-helper.net/help.htm
http://www.html-helper.net/privacy.htm

If the file "tt.htm" needed to reference "privacy.htm" it would look like this:

../../../../privacy.htm

If "privacy.htm" needed to reference "tt.htm" it would look like this:

browsers/forms/samples/tt.htm

You see? 

Okay, now comes the big question. Why not use absolute addressing all of the time?

Well, let's say your site is hosted on Geocities.Com and you are using absolute addressing. Now you move it to Bizland.Com. Because you are using absolute addressing you must go through and change every single reference from Geocities to Bizland. This is very tedious (I know, I did it once before I found out about relative addressing).

And that's all I've got to say about that.