Site hosted by Angelfire.com: Build your free website today!

Absolute vs. Relative Pathnames when Linking


Go To Styles Page

Go To Image Comparison Page

Go To Class Home Page

Absolute vs. Relative Pathnames

The term pathname refers to the location of a particular file on a computer. Typically a pathname can include a specific drive, specific folders on the drive, specific subfolders, and then a specific file. This would be the path to get to the file in question. HTML supports two kinds of paths: absolute paths and relative paths. I will attempt to discuss the differences between the two formats.

The absolute path spells out exactly where the file is located on the computer. For example, if you needed to access file ABC.html which is located in subfolder Pages which is located in folder Home, on the A: drive, the absolute pathname would look like this:

/A|/Home/Pages/ABC.html

Notice that the path name begins with a slash (/) and there is a slash separating the drives, folders, subfolders, and file name. Also, if you access a file on a different drive, you need to include a pipe ( | ) after the drive letter. One of the problems with using this format is that path names can become very long and cumbersome and can be very confusing.

A relative path will be the file's location in relation to the current Web document. In the above example, the web page ABC.html is located on the (A:) drive in the subfolder (Pages) which is located in the folder (Home). If the ABC.html code referenced a file located in the (Pages) subfolder, it would only need to reference the file name. If a relative path is used, the browser will use the folder where the HTML file is located. For example, if ABC.html code references the image school.jpg, the absolute path name would be (/A|/Home/Pages/school.jpg). For a relative path, the HTML code would only need to refer to the file name of school.jpg. If the file is in a folder above the current folder in the hierarchy, you would use two periods (..) to jump back to the previous folder. For example, if the image file school.jpg were located in the (Home) folder, the HTML code would look like this (../school.jpg). You may also have noticed that a slash is not needed at the very beginning of the path like in the case of and absolute pathname. Relative paths tend to be less confusing and much easier to code.

Absolute Pathnames
  1. Identifies the exact location of the file on the computer.
  2. The full path name must begin with a slash.(/)
  3. If referencing a different drive, path name must begin with a pipe ( | ).
  4. Path names can be very long and cumbersome.
  5. The long path names can be confusing for developers.
Relative Pathnames
  1. Gives file location in relation to the current web document.
  2. The path name does not begin with a slash (/).
  3. Need to use 2 periods (..) to reference a file in a folder above the current folder.
  4. Path names tend to be much smaller and easier to deal with.
  5. Makes the hypertext links portable.

Hi, my name is Spike from Buffy the Vampire Slayer. Click my picture to see what happens to me when I get mad!!

Go to top of page
Email Paul Wilson

Thanks for Visiting My Linking types Comparison Page!