ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 5 January 1998

4.13.2 NAME attribute in an Anchor

As mentioned in the anchors overview section, anchors mark the beginning or end of hypertext links. The NAME attribute (which is optional) marks the anchor as a possible destination of a link from another document, or from somewhere else within the same document.

The value assigned to a NAME should be a name token.

NOTE -- HTML 4 suggested renaming the NAME attribute in anchor elements to an attribute named ID. Don't do this yet -- there are no current browsers that recognize the ID attribute as the target of hypertext links. You can expect browsers that do recognize ID attributes to appear sometime in 1999 (with luck!)


Usage of NAME

Here is a typical example:

<A NAME="poison"> Toadstools </A>

Where the identifier poison is used to NAME the anchored text as the possible target of a hypertext link. The reference identifier can be an arbitrary string, but it must be unique within the document.


Targeting NAMEd Anchors

Named anchors can be targeted, from within the same document, using HREF - you simply HREF the name, prepending a `#':

<A HREF="#poison"> Poisonous non-mushrooms </A>

you can also target the NAMEd anchor from another document, simply by adding the NAME after the document URL. For example, if the identifier `poison' was located in the file `toads.html' it could be referenced by either

<A HREF="toads.html#poison"> Poisonous non-mushrooms </A>

or

<A HREF="http://www.site.edu/slimy/toads.html#poison"> Poisonous 
non-mushrooms </A>.

Active Example Of NAME

Here, for example, is a link back to the top of this page. The coding is <a href="#top">top of this page</a>.


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 5 January 1998