Creating Links

Contents:

Summary of Tags Related to Linking
Simple Hypertext Links
Linking Within a Document
Affecting the Appearance of Links
Targeting Windows
Imagemaps
Non-Web Links and Protocols
Linking Documents with <link>

The HTML 4.01 specification puts it simply and clearly: "A link is a connection from one web resource to another." This ability to link one document to another is what makes HTML unique among document markup languages and is the key to its widespread popularity.

This chapter focuses on the HTML tags related to linking and building relationships between documents. It includes uses for the anchor tag, linking with imagemaps (both client- and server-side), affecting the appearance of hyperlinks, creating links with non-web protocols, and associating documents with the link tag.

Summary of Tags Related to Linking

In this section, browser support for each tag is noted to the right of the tag name. Browsers that do not support the tag are grayed out. Tag usage is indicated below the tag name. Start and end tags are required unless otherwise noted. "Deprecated" means that the tag or attribute is currently supported but is due to be phased out of the HTML specification and is discouraged from use (usually in favor of similar style sheet controls). The attributes listed for each tag reflect those in common use. A more thorough listing of attributes for each tag, according to the HTML 4.01 specification, appears in Appendix A, "HTML Elements"

<a> NN 2, 3, 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<a>...</a>

Defines an anchor within the document. An anchor is used to link to another document or web resource. It can also serve to label a fragment within a document (also called a named anchor), which serves as a destination anchor for linking to a specific point in an HTML document.

Attributes

The attributes labeled "HTML 4.01" are new to the HTML 4.01 specification and are generally supported only by Internet Explorer 5.5 and higher and Netscape 6.

Link Examples

To a local file:

<A href="filename.html">...</A>

To an external file:

<A href="http://web.archive.org/web/server/path/file.html">...</A>

To a named anchor:

<A href="http://web.archive.org/web/server/path/file.html#fragment">...</A>

To a named anchor in the current file:

<A href="#fragment">...</A>

To send an email message:

<A HREF="mailto:username@domain">...</A>

To a file on an FTP server:

<A HREF="ftp://server/path/filename">... </A>


<area> NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<area> (no end tag)

The area tag is used within the <map> tag of a client-side imagemap to define a specific "hot" (clickable) area. Client-side imagemaps are discussed later in this chapter.

Attributes

<base> NN 2, 3, 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<base> (no end tag)

Specifies the base pathname for all relative URLs in the document. Place this element within the <head> of the document.

Attributes

<link> NN 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<link> (no end tag)

Defines a relationship between the current document and another document. This tag goes within the <head> portion of the document. It is often used to refer to an external style sheet.

Attributes

<map> NN 2, 3, 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<map>...</map>

Encloses client-side imagemap specifications. Client-side imagemaps are discussed later in this chapter.

Attributes