Linking

The chief power of HTML comes from its ability to link text and/or an image to another document or section of a document. A browser highlights the identified text or image with color and/or underlines to indicate that it is a hypertext link (often shortened to hyperlink or just link).

HTML's single hypertext-related tag is <A>, which stands for anchor. To include an anchor in your document:

  1. start the anchor with <A (include a space after the A)
  2. specify the document you're linking to by entering the parameter HREF="filename" followed by a closing right angle bracket (>)
  3. enter the text that will serve as the hypertext link in the current document
  4. enter the ending anchor tag: </A> (no space is needed before the end anchor tag)

Here is a sample hypertext reference in a file called index.html:

    <A HREF="preference.html">Preferences</A>

This entry makes the word Preferences the hyperlink to the document preference.html, which is in the same directory as the first document.

URLs

The World Wide Web uses Uniform Resource Locators (URLs) to specify the location of files on other servers. A URL includes the type of resource being accessed (e.g., Web, FTP), the address of the server, and the location of the file. The syntax is:

scheme://host.domain [:port]/path/ filename

where scheme is one of

file
a file on your local system
ftp
a file on an anonymous FTP server
http
a file on a World Wide Web server
WAIS
a file on a WAIS server
news
a Usenet newsgroup
telnet
a connection to a Telnet-based service

The port number can generally be omitted. (That means unless someone tells you otherwise, leave it out.)

For example, to include a link to this primer in your document, enter:

<A HREF="http://geocities.datacellar.net/Hollywood/Heights/4734/preference.html">
Preferences</A>

This entry makes the text Preferences a hyperlink to this document.

There is also a mailto scheme, used to hyperlink email addresses, but this scheme is unique in that it uses only a colon (:) instead of :// between the scheme and the address. You can read more about mailto below.

Links to Specific Sections

Anchors can also be used to move a reader to a particular section in a document (either the same or a different document) rather than to the top, which is the default. This type of an anchor is commonly called a named anchor because to create the links, you insert HTML names within the document.

This guide is a good example of using named anchors in one document. The guide is constructed as one document to make printing easier. But as one (long) document, it can be time-consuming to move through when all you really want to know about is one bit of information about HTML. Internal hyperlinks are used to create a "table of contents" at the top of this document. These hyperlinks move you from one location in the document to another location in the same document. (Go to the top of this document and then click on the Links to Specific Sections hyperlink in the table of contents. You will wind up back here.)

You can also link to a specific section in another document. That information is presented first because understanding that helps you understand linking within one document.

Links Between Sections of Different Documents

Suppose you want to set a link from document A (index.html) to a specific section in another document (preference.html).

Enter the HTML coding for a link to a named anchor:

     index.html:
    
     In addition to the many file, Preference is also home to 
     <a href="preference.html#ANP">Preferences</a>.

Next, create the named anchor (in this example "preference") in index.html:

  <H2><A NAME="preference">Preferences</a></H2>
 
With both of these elements in place, you can bring a reader directly to the Acadia reference in index.html.

Links to Specific Sections within the Current Document

Be sure to include the <A NAME=> tag at the place in your document where you want the link to jump to (<A NAME="ANP">Acadia National Park</a>).

Named anchors are particularly useful when you think readers will print a document in its entirety or when you have a lot of short information you want to place online in one file.

Mailto

You can make it easy for a reader to send electronic mail to a specific person or mail alias by including the mailto attribute in a hyperlink. The format is:

<A HREF="mailto:tashu74@yahoo.com">Name</a>
For example, enter:
 <A HREF="mailto:tashu74@yahoo.com">
 Taku Ashu</a>














Last Updated on the June 01st.2002



This page hosted byGEOCITIES Get your own Free Homepage
1