HTML and CSS Reference
In-Depth Information
To create a link to a fi le located in a folder other than the current document's folder,
you must specify that fi le's location, or path . HTML supports two kinds of paths: absolute
and relative.
To make your Web
site easier to maintain,
organize your folders to
match the organization of
the pages on the Web site,
and group images and
other media files within
folders separate from your
HTML files.
Absolute Paths
An absolute path specifi es a fi le's precise location within the entire folder structure of a
computer. Absolute paths employ the syntax
/ folder1 / folder2 / folder3 / fi le
where folder1 is the top folder in the hierarchy, followed by folder2 , folder3 , and
so forth, down to the fi le you want to link to. Figure 2-15 shows how you would express
absolute paths to the four fi les listed in Figure 2-14.
Figure 2-15
Absolute paths
Absolute Path
The tips1.htm file located in the pages/tips subfolder
The tips2.htm file located in the pages/tips subfolder
The glossary.htm file located in the pages/glossary subfolder
The index.htm file located in the camshots folder
If fi les are located on different drives as well as in different folders, you must include
the drive letter in the path
/ drive |/ folder1 / folder2 / folder3 / fi le
where drive is the letter assigned to the drive. For example, the tips1.htm fi le located on
drive C in the /camshots/pages/tips folder would have the absolute path
Note that you don't have to include a drive letter if the linked document is located on
the same drive as the current fi le.
Because hypertext links
cannot contain blank
spaces, avoid blank spaces
in the names you give
to your Web site folders
and files.
Relative Paths
When many folders and subfolders are involved, absolute paths can be cumbersome
and confusing to use. For this reason, most Web designers prefer to use relative paths. A
relative path specifi es a fi le's location in relation to the location of the current document.
If the fi le is in the same location as the current document, the relative path is simply the
fi lename. If the fi le is in a subfolder of the current document, include the name of the
subfolder without the forward slash, as follows
folder / fi le
where folder is the name of the subfolder, which is also known as a child folder . Note
that folders used in relative paths are often referenced using relative names, such as parent,
child, sibling, and so forth. For example, to go farther down the folder tree to other sub-
folders, include those folder names in the relative path separated by forward slashes, as in
folder1 / folder2 / folder3 / fi le
Search WWH ::

Custom Search