LINKING LOCAL PAGES USING RELATIVE AND ABSOLUTE PATH NAMES
The example in the preceding section shows how to link together pages that are contained in the same folder or directory on your local disk (local pages). This section continues that thread, linking pages that are still on the local disk but might be contained in different directories or folders on that disk.
NOTE
Folders and directories are the same thing, but they’re called different namesdepending on whether you’re on Macintosh, windows, or UNIX. I’ll simply call them directories from now on to make your life easier.
When you specify just the filename of a linked file within quotation marks, as you did earlier, the browser looks for that file in the same directory as the current file. This is true even if both the current file and the file being linked to are on a server somewhere else on the internet; both files are contained in the same directory on that server. It is the simplest form of a relative path name.
Relative path names point to files based on their locations relative to the current file. They can include directory names, or they can point to the path you would take to navigate to that file if you started at the current directory or folder. A path name might, for example, include directions to go up two directory levels and then go down two other directories to get to the file.
To specify relative path names in links, you must use-style paths regardless of the system you actually have, you therefore separate directory or folder names with forward slashes (/)., and use two dots to refer generically to the directory above the current one(…).
Table 5.1 shows some examples of relative pathnames and where they lead.
TABLE 5.1 relative path names
Path name means
path name
|
means
|
Href=”file.html”
|
File. Html is located in the current directory.
|
Href-“files/file.html”
|
File.html is located in the directory called files (and the files directory is located in the current directory).
|
Href=”files/more files/file.html”
|
File.html is located in the more files directory, which is located in the files directory, which is located in the current directory.
|
Href=”…/file.html”
|
File.html is located in the directory one level up from the current directory (the parent directory).
|
Href=”../../files/file.html”
|
File. Html is located two directory levels up, in the directory files.
|