|
Instructional Module W23d
|
|
||
Overview |
| There are two ways of linking from an HTML file to other resources (files, images, style sheets, and others):
When you create a link to Web pages outside your site, you need to give the entire URL - for example,
|
Example 1 |
|
|
Same Directory |
A level-link is one that refers to a file in the same directory as the linking file. When I want to include a link in this module to another instructional module, I don't give the entire URL because all the modules are in the same directory - both on the server and on my own computer. Suppose I want a link to module W55h "Uploading and Updating your Web Site". I link it simply with the file name w55h.htm . Browsers know that wherever the current module, w23d, came from, this other module should be in the same directory. The browser will fill in the address... If I'm viewing it on my own computer, this file's address is:
so it completes the reference to the other file, making it
If I'm viewing this page on the Web, its address is
so the browser completes the address this way:
|
Different Directories |
What if the files are in different directories? The file I want to link to may be on the same server, but in a different directory. The directory may be in any of three possible relationships with the file I'm working in:
In these examples, we'll be using this module's HTML file as the "current file". Its complete URL is:
|
Example 2 |
|
Example Web Site: www.webshop.com
Figure 1. (Assume all Web files end with .htm and all images end with .gif.) The index file in the third row (pink) is the file we're working on in this example. This will be our "linking file" in this example. We want to link to a number of other files. But first: what is its complete URL?
|
|
The (X)HTML to do this is the simplest: just put the name of the file in the Href parameter. In this example, guide.htm is in the same directory. Here is the link to it:
|
|
|
Down-links
|
A down-link is one the refers to a file in a subdirectory contained in the same directory as the linking file. An example here is the file fiction.htm in the books directory. Here is the link:
Use:
|
Up-links
|
Up-links are one that point to a file in a directory above the linking file. Let's link to the file about.htm in the public_html directory:
Use:
|
Links that go to a file in a completely different subdirectory are over-links or "cross-links". The reference points up from the current directory, then down to another subdirectory, through a series of subdirectories if necessary. Let's refer to icon1.gif in the "new" subdirectory of the "images" directory:
Use:
|
|
Try It! |
Try this for practice:
|
About this Document |
|
| Audience
|
This module is for people who are familiar with how links work in general (see module W23c) and need to learn how relative addressing works.
|
| Objectives | On successful completion of this module, you will be able to:
|
| Module W23d: Understanding Relative and Absolute Addressing | This document is part of a modular
instruction series in Computer Instruction. For more information, see
the overview
or the list of modules in this series, W: Wold Wide
Web. This document has been used in the following classes: INP
150. |
| History: | Original: 19 October 2003, by
Laurence J. Krieg Last modification: Thursday, 18-Nov-2004 21:45:19 EST |
| Copyright | Copyright © 2003, Laurence
J. Krieg, Washtenaw Community College Instructors: You may point to this file in your Web-based materials; however, its location may change without notice. Students: You are welcome to make a copy for your personal use. All other uses: Please contact the author, Laurence J. Krieg, for permission: krieg@ieee.org. |