Login for Software or Support

CoffeeCup - HTML Editor, Flash & Web Design Software

Over 47,729,286 Downloads in 87 Countries

Tell a Friend About Our Cool Software

Buy the Book Here !

Chapter 2: Hyperlinks


To create a hyperlink you use the <a> tag. The syntax is:

<a href="URL">Link text</a>

In the browser, Link text will be displayed with the special hyperlink formatting, usually a blue underline. When the user clicks the link the browser will navigate to the location specified by URL. You can also use an image for the link by inserting an <img> tag within the <a> tags:

<a href="URL"><img src="linkimage.gif" /></a>

In both cases, the mouse pointer changes to a hand icon when over a link in the browser. In either case it is important to include the http:// part of the URL:

<a href="http://www.coffeecup.com">CoffeeCup Software</a>

Many links on a Web page are often to other pages on the same Website. If the target page is in the same folder as the current page, then the <a> tag needs to include only the name of the target page:

<a href="privacy.htm">Privacy policy</a> If the target page is in a different folder on the same Website, then the link must indicate the file location:

<a href="docs/privacy.htm">Privacy policy</a>

To link to an anchor in a Web page, put the anchor name at the end of the URL separated by a pound sign (#):

<a href="http://www.coffeecup.com#AnchorName">CoffeeCup Software</a>

You can also link to an anchor that is in the same document as the hyperlink. In this case use just the anchor name, preceded by #, as the URL:

<a href="#AnchorName">Link text</a>

You can use a hyperlink to let the user download a file onto their computer. All you need to do is specify the file name as the href attribute. This link, for example, will let the user download the specified ZIP file:

<a href="SourceCode.zip">Download source code</a>

Please see the sidebar Links to Other File Types for more information on downloading files

Links to other File Types

You can create a hyperlink to any kind of file--images, word processing documents, Excel spreadsheets, ZIP files, executable program files, and so on. What happens when a user clicks a link depends on the file extension, which identifies the type of file.

If the file is a recognized Web file it is opened in the browser. This includes HTML documents (.htm and .html extensions), Web images (.gif, .jpg, and .png extensions), and script files (.asp, .php, and .jsp extensions).

If the file is another type, the user has the option to download it or to, in most cases, to open it. For downloading, the user will be permitted to select the download folder. The opening option is available only if the user has the associated application installed, such as Microsoft Word for files with the .doc extension. If the user chooses the Open option, the file is downloaded to a temporary folder and then opened.

You need to be aware that security software will sometimes block the download of certain file types that can be used to spread viruses. This is often the case for executable program files (.exe extension) but can be applied to other file types as well.

Anchors

You also use the <a> tag to create an anchor, using the name attribute instead of the href attribute:

<a name="AnchorName">Text to be anchored</a>

Each anchor name must be unique within the document. Text that is anchored is not displayed in any special way. You can create an "empty" anchor by simply not including any text within in <a> tag:

<a name="AnchorName"></a>

Anchors function the same, however, whether empty or not.


Table of Contents
CoffeeCup Home Page | Software | Copyright & Legal | Site Map | © 1996 - 2008 CoffeeCup Software, Inc.