Links and Images in (X)HTML | |||
| |
| Links are what give the Web its power: the power to leap effortlessly from one part of the world to another with a single click of the mouse. Or to put it more technically, a link is an instruction to a browser to seek a Web page (or other service) from a server. So: how do we create (X)HTML links? | |||||||||||||||||
Building a Link
| Here is a link in (X)HTML, and what it looks like in the browser:
From this example you can see that there's a lot more to a link than meets the eye! Let's look at the parts...
| ||||||||||||||||
Targets | Ordinarily, a hyperlink opens a file in the same window as the originating link, so that the new file replaces the old one. There are times when that's not ideal, and it would be better if the new file were "shot" into a different window. A target is the window in which a hyper-reference will appear. The target is assumed to be the same window as the link, unless there is a Target parameter in the Anchor tag. Here's what one looks like (highlighted):
What the browser shows is exactly the same with and without the Target parameter - a user wouldn't know that clicking this link will open the file in a different window. (Try it!) There are several possibilities for what you can name as the "target". Notice that several of them begin with an _underscore_ character:
| ||||||||||||||||
Window Names | The target names shown above are standard names, and need to be spelled as you see them, with _underscore_ characters in front of them. But you can put in any name you want! This makes it possible for you to give names to windows. Here's how it works... You put in a link with a target name. For example:
The first time the user clicks the link (try it!) the browser opens a new window and remembers it as Piglet. The name Piglet is not part of the (X)HTML code in the linked file - it's just something the browser keeps track of for itself. Now you create another link. The target is the Piglet window, but the link is to a different file. (Try this one, too.)
| ||||||||||||||||
| At the start, we said a link is an instruction to a browser to seek a Web page (or other service). One of the reasons the Web has become so popular is the variety of services it can give us access to. It's done fairly simply by specifying the protocol to be used in talking to the server. This lets the browser know what kind of service is needed. | |||||||||
Web Pages | Web pages are what we naturally expect browsers to get for us - and what they expect to get, too. The page's file may be located on the same computer as the browser (a local file) or on a server.
| ||||||||
|
| An email link is useful for encouraging visitors to a Website to send feedback to the designer - or to anyone else! Email links are simple to create. Here are some examples:
| ||||||||
Other Types | In addition to asking for Web pages and sending email, hyperlinks can be used for several other types of Internet exchanges. Here are a few of them:
| ||||||||
About this document... |
|
|---|---|
Review: |
Link to review questions and answers. |
Audience: |
This is for people who have created a minimal (X)HTML page (see module W22h) and understand the general principles of (X)HTML (see module W22c). |
Objectives: |
When you successfully complete this lesson, you will be able to identify and explain the...
|
Module W23c: |
This document is part of a modular instruction series in Computer Information Systems. For more information, see the overview or the list of modules in this series, W: World Wide Web. This document has been used in the following classes: |
Author: |
Laurence J. Krieg |
Institution: |
|
| History: | Original: 09 November 2000;
XHTML update 03 October 2003 Last modification: Tuesday, 17-Feb-2004 12:39:28 EST |
| Copyright: | Copyright © 2003,
Laurence J. Krieg. Instructors: You may point to this file in your Web-based materials. Students: you may make a copy for your personal use. All other uses: contact the author, Laurence J. Krieg for permission. Email krieg@ieee.org |