F&M Home  | About the College  | Academics  | Admission  | People & Services  | Student Life
ATSFranklin & Marshall College
About ATS  |   Faculty Support  |   Student Support  |   Resources  |   Events   |  Facilities
ATS Home
Resources
Learning Materials
Software Tools
Tech News
Bookmarks
Clip Media

 

Linking: Absolute and relative path URLs

Prev | Next | HTML Basics
print:

Absolute Path URLs

URLs can be either absolute or relative. An absolute URL shows the entire path to the file, including the scheme, server name, the complete path, and the file name itself . An absolute URL is analogous to a complete street address, including name, street and number, city, state, zip code, and country. No matter where a letter is sent from, the post office will be able to find the recipient. In terms of URLs, this means that the location of the absolute URL itself has no bearing on the location of the actual file referenced—whether it is in a Web page on your server or on mine, an absolute URL will look exactly the same.

path:

A URL with a trailing forward slash and no file name points to the default file in the last directory named (in this case the liz directory). Some common default file names are index.html and default.htm.

Relative Path URLs

To give directions to your neighbor's house, instead of giving the complete address, you might just say "it's four doors down on the left". This is a relative address—where it points to depends on you start. With the same information in a different city, someone would never find your neighbor.

path1:

The relative URL for a file in the same folder as the file that contains the link is just the file's name and extension.

In the same way, a relative URL describes the location of the desired file with reference to the location of the file that contains the URL itself. So, you might have the URL say something like "show the xyz image that's in the same directory as the current file".

path2:

For a file that is within a folder inside the current folder, add the folder's name and a forward slash in front of the file name.

In this case, the relative URL for a file that is in the same directory as the current file (that is, the one containing the URL in question) is simply the file name and extension. You create the URL for a file in a subdirectory of the current directory with the name of the subdirectory followed by a forward slash and then the name and extension of the desired file.

path3:

This file is in a folder that is inside the folder that contains the current folder. In that case, you use two periods and a slash to go up a level, and then note the subdirectory, followed by a forward slash, followed by the file name.

To reference a file in a directory at a higher level of the file hierarchy, use two periods and a forward slash. You can combine and repeat the two periods and forward slash to reference any file on the same hard disk as the current file.

Generally, you should always use relative URLs. They're much easier to type and they make it easy to move your pages from a local system to a server—as long as the relative position of each file remains constant, the links will work correctly. One added advantage of relative URLs is that you don't have to type the scheme-as long as it's HTTP.

Prev | Next | HTML Basics
print:


 

Locations of visitors to this page

Search within Resources or across the entire site.

 
 Search within Resources only.

Site Map

 

Copyright 2008 Franklin & Marshall College