Writing@CSU

Writing Guides

Writing for the Web

 

Making Links

In HTML, a link is referred to as an "anchor." The tag for an anchor is <A>. Like other tags, you begin a link with an <A> and end it with an </A>. The text that you want to make a link goes between these two tags.

Like an image tag, an anchor tag will not function without attributes. The most frequently used attributes for the anchor tag are:

Attribute Definition and Values
HREF Specifies the document that is opened when the link is activated. HREF can specify a link to a document, a named location within a document, a file, an email address, an FTP site, a telnet site. In short, an HREF can specify anything that can be viewed or started from a browser.
TITLE In newer browsers, this information is displayed when the cursor is placed over the link.
TARGET Specifies the frame or window in which the link is opened. TARGET is an important attribute in framed sites, which are discussed in the coding primer, Using Frames. A target can have any name -- Biff or Bob will each do, as will Socrates and Linda. Four names are reserved for specific functions:
  • _blank Opens the link in a new, unnamed browser window.
  • _self Opens the link in the current window. This is the default for all untargeted links.
  • _top Opens the link in the current window, whether or not the document containing the link is in a frame.
  • _parent Opens the link in the "parent" frame.
NAME Specifies a named location within a document.

Note: Additional attributes include ACCESSKEY, CHARSET, TYPE, and TABINDEX. You can learn more about these and other attributes on a site that discusses HTML tags in more detail, such as the HTML Compendium at http://www.htmlcompendium.org, or in a book such as Jennifer Niederst's HTML Pocket Reference, published by O'Reilly (info on the Web at http://www.oreilly.com/catalog/htmlpr/).

Creating Links to Other Documents

Creating a Simple Link:
<A HREF="links.cfm">View a list of key HTML and Web resources</A>.
View a list of key HTML and Web resources.
Adding a Title to a Link:
<A HREF="links.cfm" Title="These Resources Are Worth Checking Out">View a list of key HTML and Web resources</A>.
The title will display in newer browsers: View a list of key HTML and Web resources.
Targeting a Link
<A HREF="links.cfm" TITLE="These Resources Are Worth Checking Out" TARGET="_blank">View a list of key HTML and Web resources</A>.
This link will open in a new window: View a list of key HTML and Web resources.

Creating Links to Non-Web Pages and Objects

Email Addresses:
<A HREF="mailto:Mike.Palmquist@ColoState.edu" Title="Send Mike an Email Message">Mike.Palmquist@ColoState.edu</A>.
This link uses the mailto: prefix to specify an email address: Mike.Palmquist@ColoState.edu.
Linking to FTP, Telnet, Newsgroup, and Gopher Sites:
<A HREF="ftp://ftp.ipswitch.com" Title="Visit the Ipswitch FTP Site">Visit Ipswitch's FTP Site</A>.
This link uses the ftp: prefix to specify an FTP (file transfer protocol) site. Other prefixes include telnet:, news:, and gopher:. Visit Ipswitch's FTP Site.
Linking to Files
<A HREF="image_demo.cpt" Title="Download this Corel PhotoPaint File">image.cpt</A>.
This link will allow you to download a file that can't be viewed in a Web browser: image_demo.cpt.

Creating and Linking to Named Anchors

<A NAME="attributes"></A>.
This anchor specifies a location in the file you are currently reading. It is not visible in the document.
<A HREF="#attributes" Title="Return to the Attributes List">Attributes List</A>.
To link to a named anchor in the current document, use a pound sign ( # ) before the name of the link: Attributes List.
If you were linking to this named anchor from another document, you could use this code:
<A HREF="primer_links.cfm#attributes" Title="View the Attributes List in the Links Primer">Attributes List</A>.
See Also
Coding Primer: To learn how to code links in framed Web sites, view the coding primer, Using Frames.

Copyright © 1993-2009 Colorado State University and/or this site's authors, developers, and contributors. Some material displayed on this site is used with permission.