A - Anchor

Syntax
<A>...</A>

Attribute Specifications
[Key] [3.2] HREF=URL (hypertext reference)
[3.2] METHODS=list of HTTP Methods.
[Key] [3.2] NAME=CDATA (named link destination)
[3.2] REL=LinkTypes (relationship to link)
[3.2] REV=LinkTypes (relationship from link)
[3.2] SDAPREF
[3.2] TITLE
[3.2] URN
[3.2] TARGET=FrameTarget (frame to render link in)
[4.0] ACCESSKEY=Character (shortcut key)
[4.0] CHARSET=Charset (character encoding of link)
[4.0] CLASS
[4.0] COORDS
[4.0] DIR
[4.0] ID
[4.0] LANG
[4.0] SYSTEM EVENTS (ONCLICK etc.)
[4.0] SHAPE=[ rect | circle | poly | default ] (client-side image map)
[4.0] STYLE
[4.0] TABINDEX=Number (position in tabbing order)


Common Attributes


Can Contain:
Inline elements except A

Contained in:
Block-level elements, inline elements except A


Description

The A element denotes an anchor--a hypertext link or the destination of a link. The HREF attribute specifies a hypertext link to another resource, such as an HTML document or a JPEG image. Examples:


[Key] [3.2] HREF

The value of the HREF attribute is the URL of the link. The TYPE attribute can be used to specify the Internet media type of the link, allowing browsers to avoid fetching a resource that they cannot handle.

[3.2] METHODS

"This is a comma separated list of HTTP methods supported by the linked object. The browser might choose a different way of rendering the link for say searchable objects." (HTML+).
METHODS is expected to be a white-space-separated list of HTTP methods supported by the object and accessible to the user. RFC 1866 suggests that the content of the anchor element may be rendered differently depending upon the HTTP method.
(From the HTML COMPENDIUM)

[Key] [3.2] NAME

NAME and ID values must be unique in any document, and different values must differ by more than just the case. Values must begin with a letter in the range A-Z or a-z, and may be followed by A-Z, a-z, 0-9, hyphens, underscores, colons, or periods. When linking to a named anchor, the name is treated as case sensitive.

[3.2] REL & REV

The REL and REV attributes define relationships between an anchor and the linked resource. REL defines a link relationship from the current document to the linked document while REV defines a relationship in the opposite direction. For example,

<A HREF="foo.html" REL=glossary>...</A>

indicates that foo.html is a glossary for the current document while

<A HREF="bar.html" REV=subsection>...</A>

indicates that the current document is a subsection of bar.html. The value of the REL and REV attributes is a space-separated list of link types.

[3.2] SDAPREF

Unknown at this time

[3.2] TITLE

The TITLE attribute can be used to briefly describe the contents of the link and is rendered as a "tooltip" by some visual browsers. With mailto links, some browsers use the TITLE attribute value as a subject for the e-mail message.
Note: The content of an A element used as a link should be as context-free as possible. In other words, a user should be able to pull all A elements from a document and still have an idea what lies behind each link. Link text that contains Click here or simply here is extremely bad form.

[3.2] URN
Universal Resource Indicator. See the HTML Compendium for more details.


[3.2] TARGET

The TARGET attribute is used with frames to specify in which frame the link should be rendered. If no frame with such a name exists, the link is rendered in a new window unless overridden by the user. Special frame names begin with an underscore:

  • _blank renders the link in a new, unnamed window
  • _self renders the link in the current frame (useful for overriding a BASE TARGET)
  • _parent renders the link in the immediate FRAMESET parent
  • _top renders the link in the full, unframed window
[4.0] ACCESSKEY

The ACCESSKEY attribute specifies a single Unicode character as a shortcut key for following the link. Entities (e.g. &eacute;) may be used as the ACCESSKEY value.

[4.0] CHARSET

The CHARSET attribute defines the character set the borwser should use when rendering the page pointed to by by the link.

[4.0] CLASS

Used with Cascading Style Sheets. For more information, see the WDG help on Cascading Style Sheets. xxxx-->

[4.0] COORDS

The SHAPE and COORDS attributes of A can be used to create client-side image maps via the OBJECT element. The default SHAPE value is rect, which defines a rectangular region using COORDS="left, top, right, bottom". Other SHAPE values are

Coordinate values are relative to the top left corner of the object and may be expressed as pixels or percentages. A percentage radius value for circular regions is calculated relative to the smaller of the object's width and height. If two or more regions overlap, the earliest specified region takes precedence.

In addition to the core events common to most elements, A accepts the following event attributes for client-side scripting:

[4.0] DIR

The DIR attribute value is one of LTR for left to right, or RTL for right to left, e.g. DIR=RTL. Currently this attribute is supported by niether Netscape or MS Internet Explorer.

[4.0] ID

The NAME attribute defines a destination for a link. For example, a document containing

<H1><A NAME=foo>My Heading</A></H1>

defines a link destination named "foo" at the indicated heading. One could then use HREF="#foo" in an A element within the same document or HREF="somedoc.html#foo" from within another document.

An A element cannot contain another A element, so one must be careful that named anchors do not contain link anchors. Authors can use both the NAME and HREF attributes in a single A element to avoid this problem.

HTML 4.0's ID attribute is intended to eliminate the need for A NAME. The ID attribute can be used with almost any element to define a link destination, so that the following could be used in place of the previous example:

<H1 ID=foo>My heading</H1>

However, browser support for ID link destinations is very poor, so A NAME will be needed for quite awhile.

[4.0] LANG

This attrbute describes the language and dialect that the text is written in. For example:

<tag lang="en-cockney"> or <tag lang="i-cherokee">

[4.0] SYSTEM EVENTS

A number of attributes that define client-side scripting events are common to most elements. The attribute value is a script--typically a function call or a few short statements--that is executed when the event occurs. The value may contain entities (e.g., &quot;).

The following example features JavaScript code to handle two events of a submit button, giving the user a reminder in the status bar when the mouse moves over the button and clearing the status bar when the mouse moves away. Note that the attribute values are delimited by single quotes since double quotes are used within them.

<INPUT TYPE=submit ONMOUSEOVER='window.status="Did you fill in all required fields?";' ONMOUSEOUT='window.status="";'>

When an event attribute is used, a default scripting language must be specified for the document by setting the Content-Script-Type HTTP header to the media type of the scripting language. The previous example could use the following META element in the document's HEAD:

<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">

The common event attributes are device-dependent and largely tailored for the graphical user interface. The available events are as follows:

[4.0] SHAPE

The SHAPE and COORDS attributes of A can be used to create client-side image maps via the OBJECT element. The default SHAPE value is rect, which defines a rectangular region using COORDS="left, top, right, bottom". Other SHAPE values are

Coordinate values are relative to the top left corner of the object and may be expressed as pixels or percentages. A percentage radius value for circular regions is calculated relative to the smaller of the object's width and height. If two or more regions overlap, the earliest specified region takes precedence.

In addition to the core events common to most elements, A accepts the following event attributes for client-side scripting:

[4.0] STYLE

One of several ways of using Cascading Style Sheets in your documents, the 'STYLE' attribute is used to set a previously defined style to a tag. For example:

<A STYLE="background-color:'lime'">

[4.0] TABINDEX

The TABINDEX attribute specifies a number between 0 and 32767 to indicate the tabbing order of the element. An anchor with TABINDEX=0 or no TABINDEX attribute will be visited after any elements with a positive TABINDEX. Among positive TABINDEX values, the lower number receives focus first. In the case of a tie, the element appearing first in the HTML document takes precedence.

More Information