![]() |
![]() |
The purpose of this page is to demonstrate some of the features of HTML that you should be using in your work.
Links are especially useful because they allow you to create pathways that users can follow across the web. Links are based on Uniform Resource Locators or URLs. Take, for example, the URL for the web location of another version of this page:
http://www.slis.indiana.edu/hrosenba/www/Demo/Demo2.html
Taking this apart, you can see that it has several distinct components:
| Protocol | Markup | Example |
|---|---|---|
| File transfer protocol | ftp:// | ftp://hostname/directory_path/filename.ext |
| Gopher | gopher:// | gopher://gopherserver:port#/directory_path |
| TELNET | telnet:// | telnet://hostmachine:port# |
| mailto:address | mailto:userID@hostname.ext |
There are two kinds of URLs
<a href="http://www.slis.indiana.edu/hrosenba/www/Demo/Demo2.html">text</A>
To use image2.gif in the document page2.htm, you have to provide instructions for the browser to
The markup for a relative URL would look like this:
<a href="../../../images/image2.gif"></a>
The ../ markup indicates to the browser that it should move up one subdirectory. In this case three are necessary to move up through the workshop subdirectory demopage subdirectory to the parent directory (www). The rest of the directory path moves down to the image.
The base element must appear between the paired head tags at the top of the document and should contain the base URL for the document. The browser that uses this URL to fill in the missing pieces of all of the relative URLs in the document.
For example, this can be useful if the current document has been moved and the other documents referenced by the relative URLs have not. You can use the base URL of the old location (where the other documents are) and they can still be located through the links in the document that has been moved. Using a base element would look like this:
<html>
<head>
<title>Whatever</title>
<base href="http:www.slis.indiana.edu/hrosenba/">
</head>
So, with this markup the document "Whatever.html" gets moved, the documents referenced in "Whatever.html" using relative URLs such as ../../images/image2.gif can be found, because the browser looks at the base URL and fills in what's missing, so it will look for the following URL when a user clicks on the relative URL:
<a href="http://www.slis.indiana.edu/hrosenba/../../images/image2.gif ></a>
<a href="http://www.slis.indiana.edu/hrosenba/www/Demo/Demo2.html">text</a>
What has been added are the two components of the anchor tag:
<a href="...>
a is the opening of the tag and href is the attribute, whose value is the URL used in the link
</a>
/a closes the anchor tag
Link to another site:
<a href="full.internet.address">text</a>
For example, to link to the syllabus, you would use:
<a href="http://www.slis.indiana.edu/hrosenba/www/L571/syllabus/Syll14.html"> Syllabus</a>
It would look like this in a line of text:
This is a link to the L571 Syllabus
Notice that the anchor is a paired tag. You have to end it with the </a> tag. If you do not, everything after your link will also be underlined and the link will not work.
Link to another document or image that you own:
<a href="page or filename.extension">text</a>
For example, to link to the previous page, you would use:
<a href="Demo.html">Demo page: Tags</a>
It would look like this in a line of text:
This is a link to the Demo page: Tags displaying HTML tags
The first part of the tag is the anchor (<A>) and defines the destination. You place this tag in the text, usually around a word on the line where you want the reader to end up. It uses the following markup:
<a name="anchor name">text</a>
The second part of the tag is the link to the anchor and defines the point from which the user can make the jump to the destination anchor. It uses the following markup:
<a href="#anchor name">text</a>
You can use names (top; contents) or numbers (Part 1) for the anchor names. You have to include the # sign in front of the anchor name.
The markup for such a link would look like this at the jumping off point:
You can use this <a href="#Part 1">link</a> to go to the top of the page.
It would look like this:
The markup at the destination point would look like this:
<a name="Part 1">Some</a>
<a name="anchor name">text</a>
In the main document, where the user will see the link, you put the following markup:
<a href="pagename.html#anchor name">text</a>
So in the destination document (which in this case is the Table of Contents (DemoCon.html), you would place the following markup tags somewhere on the page (in this case the last word of the first paragraph).
<a name="Links">current</a>
And in the document (this one) where the link appears, you would place the following markup tags in the place that will be the jumpoff point (which is the sentence that follows the markup example):
<a href="DemoCon.html#Links">link</a>
You can use this link to go to the section of the Table of Contents page with the link back to this page!.
Want to know more? Here are links to pages about HTML. Use the Back button to return to this page when you are ready to continue.
Let's move on to a page about images.
| Demo Page Navigation: |
DemoPage contents | About HTML | UNIX help | HTML tags | Lists | Links | Images |
|---|---|---|---|---|---|---|---|
| Imagemapping | Tables | Forms | Frames | Javascript | CSS (style sheets) | XML |
| Page by Howard Rosenbaum | |
| Find me at hrosenba@indiana.edu | http://www.slis.indiana.edu/hrosenba/www/Demo/Demo2.html |