1. Home
  2. Computing & Technology
  3. Web Design / HTML

Adding Internal Links
Using the Anchor Tag to Create Page Bookmarks

By Jennifer Kyrnin, About.com Guide

In another beginning HTML article, I wrote about how to add links in HTML documents.

But often you want to link to the same document, and simply skip down to the specific section referenced. Eventually, it may be possible to link to exact pixel locations in documents, but for now, you need to use the anchor tag (A) to create both the link and the location to be linked to.

First, you should create the document and decide where you want your internal links to go. You label these using the anchor tag (a) with the name and id attributes. The name and id attributes should be identical. e.g.

<a name="anchor1" id="anchor1">Anchor text</a>

Then second, you create the link to the site using the anchor tag (a) and the href attribute. You indicate the named area with a pound-sign (#). e.g.

<a href="site.html#anchor1">Anchor link</a>

The trick to this is to make sure that you have put the <a name> around text or an image. For example:

<a name="here">Here</a>

Many times you will see people who use these links without surrounding anything (e.g. <a name="1" id="1"></a>), but this is not as reliable an anchor as when you surround a word or image. Many browsers like to have some element to position at the top of the screen, and when you enclose nothing, you run the risk that the browser will be confused.

Explore Web Design / HTML
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. About.com Web Design A to Z
  5. Web Design Articles A-H
  6. Web Design/HTML Articles A
  7. Adding Internal Links - Named Anchors - Page Bookmarks>

©2009 About.com, a part of The New York Times Company.

All rights reserved.