A path is a description of the route from one file to another. For example, if you link page A to page B, the path for that link is the piece of code on page A that instructs the browser how to find page B. Image files for the pictures on a page are also referenced with a path. There are three kinds of paths:
Document-relative
A document-relative path describes the location of the file you're going to (the destination file) by describing the route the browser must take from the file you're starting with (the source file).
Here are some examples of document-relative paths:
image1.gif
This path means that the image file image1.gif is located in the same folder as the page displaying the image. In simpler terms, the path translates to: "Find a file calledimage1.gif".
images/image1.gif
This path means that, in the same folder as your page, there is an images subfolder, in which the image is located. In simpler terms, the path translates to:
- Go to a folder called images (
images/).
- Find a file called image1.gif (
image1.gif).
../images/image1.gif
This path means that you have a folder which contains two subfolders. In the first subfolder is your page, and in the second (named images) is your image. In simpler terms, the path translates to:
- Go up one folder to get out of the folder containing the page (
../).
- Go to a folder named images (
images/).
- Find a file called image1.gif (
image1.gif).
Site root-relative
A site root-relative path describes the location of the destination file by describing the route the browser must take from the Web site's root folder (top level in the folder structure).
For example, a site root-relative path to an image may appear as:
/html/images/image1.gif
The "/" at the beginning means the path is site root-relative and indicates to the browser reading the path that it must start from the Web site's root folder.
In simpler terms, the path translates to:
- Go to the root directory (
/).
- Go to the html folder (
html/).
- Go to the images folder (
images/).
- Find the file image1.gif (
image1.gif).
Absolute
An absolute path describes the physical location of a file on a machine or the exact location of a file on the Internet. An absolute path on your hard drive might appear as:
file:///c:\sites\mycoolsite\html\images\image1.gif
An absolute path on the Internet might appear as:
http://www.mysite.com/html/images/image1.gif
In simpler terms, this path would translate to:
- Go to the web site called www.mysite.com (
http://www.mysite.com/).
- Go to a folder called html (
html/).
- Go to a folder called images (
images/).
- Find a file called image1.gif (
image1.gif).