Ken Ward's HTML Tutorial ...

URLs

The URL is the file you you want to refer to in your document. Actually, it is the location of that file, or resource. URL stands for Uniform Resource Locator. Are you disappointed I said that? You have already used URLs in hyperlinks, so you know what I mean. There are absolute URLs and relative URLs (although none of my relatives are URLs).

Absolute URLs say precisely where the file in question is. For example:

  1. C:\htmltutorial\index.htm
  2. https://trans4mind.com/personal_development/index.htm
  3. file:///G:/aaWebSite/aNewTrans4/HTMLGuide/background_images.htm

The first example uses the location of a file on the C drive of a computer. The second gives a location on the web. And the last one is the location of a file on a computer using the internet convention. You will notice that the first file uses the \ convention for Windows, and the others use the / for the internet. So much for absolute files. Generally, you would use an absolute reference for a specific file on the internet. So your home page might have an absolute reference, whereas others might have a relative reference.

When writing HTML on a computer, as I am now, I use directories which have the same name as the directories in the website. However, on my computer they begin with a drive letter which isn't present on the website. For example, my home page is G:\aaWebSite\aNewTrans4\HTMLGuide\index.htm, whereas on the internet it is https://trans4mind.com/personal_development/index.htm.

To refer to files on my computer in a way which will also work on the website, I use a relative URL.

At the moment this file is in a directory called aNewTrans4\HTMLGuide on my computer. My home page is in the directory aNewTrans4, which does not exist on the website. To refer to the home page in aNewTrans4 I use a relative URL:

../index.htm"

This does not mention the directory on my computer. The ../ bit tells the browser to look for my file the parent directory of this one, whether it is looking on the website or on my computer.

But how can I refer to a file in a parallel directory? For example, there is a directory called philos which is parallel to this one. How can I refer to the main page, for example in that directory? Here's how:

../Philos/indexPhilos.htm"

Firstly, we tell the browser to move to the parent directory ../ and from there to look in Philos for the file indexPhilos.htm!

If you think about it, there is no way we can avoid having the directories below the main one sharing the names of the ones in the website. If we don't use Philos, to tell which directory is the one we mean, how could the browser find it?


[back to: hypertext links]
[home][contents]


Most Recent Revision: 18-Oct-98.
Copyright 1998

I am always pleased to hear from you.
Send your comments to