Syntax | <A>...</A> |
---|---|
Attribute Specifications |
|
Contents | Inline elements except A |
Contained in | Block-level elements, inline elements except A and BUTTON |
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:
<A HREF="album.html">My photo album</A>
<A HREF="../images/me.jpg">Picture of me</A>
<A HREF="/sounds/auldlang.mid" TYPE="audio/midi" ACCESSKEY=A>Auld Lang Syne (5 kB MIDI)</A>
<A HREF="section2.html" TARGET="content" TITLE="Elements of the HEAD" REL=next>Section 2</A>
<A HREF="mailto:liam@htmlhelp.com" TITLE="Feedback on HTML 4.0 Reference">liam@htmlhelp.com</A>
<A HREF="http://www.htmlhelp.com/" TARGET="_top">Web Design Group</A>
<A HREF="http://babel.alis.com:8080/langues/iso639.zh.htm" CHARSET="big5" HREFLANG=zh>ISO 639</A>
The value of the HREF attribute is the URI 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.
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.
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.
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:
In HTML 4.0, the TARGET attribute value is case-insensitive, so that _top and _TOP both have the same meaning. However, most browsers treat the TARGET attribute value as case-sensitive and do not recognize _TOP as having the special meaning of _top.
The optional HREFLANG and CHARSET attributes give the language and character encoding, respectively, of the link. The language should be specified according to RFC 1766; examples include en for English, en-US for American English, and ja for Japanese. Examples of character encodings include ISO-8859-1, SHIFT_JIS, and UTF-8.
The ACCESSKEY attribute specifies a single Unicode character as a shortcut key for following the link. Entities (e.g. é) may be used as the ACCESSKEY value.
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.
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.
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.
NAME and ID values must be unique in any document, and different values must differ by more than just the case. ID 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.
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: