URL types

If you used URLS, you have likely noticed both short and long URLs. Depending on the destination of the document you want to link to, your link path information will vary. If, for instance, your link destination document is on the same server as the document where the link will be placed, your link path is likely to contain less information than if you had documents on different servers. This discussion is leading to two possibilities of link categories based on the destination of documents: relative, and absolute.

Relative links

A relative type URL points to a file that is in the same root directory as the file where the link will be placed. In other words, if the destination file (to which you are linking to) and the originating file (from which you are linking) are both in the same root directory, you are likely to use relative URL. In a relative URL, you don't specify the website address (such as http://www.google.com, http://www.scriptingmaster.com, http://www.msn.com, etc.). Examples of relative link paths include:

  • /products/computers.asp,
  • ../graphic/pc1.jpg, and
  • ./../index.htm

If you still have difficulty understanding relative URLs, the following analogy may help. Think of making a local phone call within your city or state. When you make the local call, it is likely you are not using the country code. You only need to dial the local number and perhaps in addition your city area code. Your call will go through although you are not using the country code. Similarly, in linking to local files on the same root directory of the server only require file or directory names. Website address in this situation is not needed because you want to make a link to a local file.

» More on relative linking.

Absolute links

With the absolute links, not only you have to specify the directory (and file information) but also the website address. Let's go back to our earlier analogy of making phone calls to understand absolute URLs. Think of absolute URLs making national or international calls. When making non-local calls, you are likely to use country code in addition to any state or local area codes. So you need to dial extra specific numbers to successfully making an international call. Otherwise, you will just be making a local phone call.

In the context of making absolute links, you need to reference the website address otherwise you would be attempting to make links to local files on the same server. By specifying the website address when creating a link, you are instructing the browser that the linked document is outside of the current website. Think of the international call analogy. If a website address is not included in your link path, the browser will assume it is a local link (or think of making a local call analogy).