<A>NN all IE all HTML all  

<A>...</A>

HTML End Tag: Required  

The a element is the rare element that can be an anchor and/or a link, depending on the presence of the name and/or href attributes. As an anchor, the element defines a named location in a document to which any URL can reference by appending a hashmark and the anchor name to the document's URI (for example, http://www.megacorp.com/contents#a-c). Names are identifiers assigned to the name attribute (or in newer browsers, the id attribute). Content defined solely as an anchor is not (by default) visually differentiated from surrounding body content.

By assigning a URI to the href attribute, the element becomes the source of a hypertext link. Activating the link generally navigates to the URI assigned to the href attribute (or it may load other media into a helper application or plugin without changing the page). Unless modified by style sheets, links typically have a distinctive appearance in the browser, such as an underline beneath text (or border around an object) and a color other than the current content color. Attributes can define separate colors for three states: an unvisited link, a link being activated by the user, and a previously visited link (the linked document is currently in the browser cache). Such color control is deprecated in favor of CSS pseudo-classes (:link, :active, :visited, and a new state, :hover). An a element can be both an anchor and a link if, in the least, both the name (or id) and href attributes have values assigned to them.

 
Example
 
<A name="anchor3" id="anchor3">Just an anchor named "anchor3."</A>
<A href="#anchor3">A link to navigate to "anchor3" in the same document.</A>
<A name="anchor3" id="anchor3" href="http://www.megacorp.com/index.html">
Go from here (anchor 3) to home page.</A>
 
Object Model Reference
 
[window.]document.links[i]
[window.]document.anchors[i]
[window.]document.getElementById(elementID)
 
Element-Specific Attributes
 
charsetcoordsdataflddatasrchref
hreflangmethodsnamerelrev
shapetargettypeurn
 
Element-Specific Event Handler Attributes

None. Anchor-only a elements have no event handlers in Navigator through Version 4.

accesskeyNN 6 (see text) IE 4/5 HTML 4 (see text)  

accesskey="character"

Optional  

A single character key that either gives focus to an element (in some browsers) or activates a form control or link action. The browser and operating system determine if the user must press a modifier key (e.g., Ctrl, Alt, or Command) with the access key to activate the link. In Windows versions of IE 4 and later and Netscape 6, the Alt key is required and the key is not case-sensitive. For Macintosh versions of IE 5 and later and Netscape 6, the Ctrl modifier key is required to effect the action.

Although accesskey is listed here as a widely shared attribute, that isn't strictly the case across all implementations. HTML 4 and Netscape 6 recognize this attribute only for the following elements: a, area, button, input, label, legend, and textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, object, select, span, table, and td (but removes label and legend). IE 5 adds every other renderable element, but with a caution: except for input and other form-related elements, you must also assign a tabindex attribute to the IE 5 and later element (even if simply a value of zero for all) to let the accelerator key combination bring focus to the element.

 
Example
 
<A href="http://www.megacorp.com/toc.html" accesskey="t">Table of Contents</A>
		<H2 class="subsection" accesskey="2" tabindex="0">Part Two</H2>
 
Value

Single character of the document set.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].accessKey
		[window.]document.anchors[i].accessKey
		[window.]document.formName.elementName.accessKey
		[window.]document.forms[i].elements[j].accessKey
		[window.]document.getElementById(elementID).accessKey
charsetNN 6 IE n/a HTML 4  

charset="characterSet"

Optional  

Character encoding of the content at the other end of the link.

 
Example
 
<A charset="csISO5427Cyrillic" href="moscow.html">Visit Moscow</A>
 
Value

Case-insensitive alias from the character set registry (ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets).

 
Default

Determined by browser.

coordsNN n/a IE 6 HTML 4  

coords="coord1, ... coordN"

Optional  

Although defined for the a element, the coords attribute applies to the area element for client-side image maps. The area element "inherits" many attributes and behaviors of the a element. See the area element.

datafldNN n/a IE 4 HTML n/a  

datafld="columnName"

Optional  

Used with IE data binding to associate a remote data source column name in lieu of an href attribute for a link. The data source column must contain a valid URI (relative or absolute). A datasrc attribute must also be set for the element. Works only with text file data sources in IE 5/Mac.

 
Example
 
<A datasrc="DBSRC3" datafld="newsURL">Late-Breaking News</A>
 
Value

Case-sensitive identifier.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].dataFld
[window.]document.getElementById(elementID).dataFld 
datasrcNN n/a IE 4 HTML n/a  

datasrc="dataSourceName"

Optional  

Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Content from the data source to be inserted into the a element text is specified via the datafld attribute. Works only with text file data sources in IE 5/Mac.

 
Example
 
<A datasrc="DBSRC3" datafld="newsURL">Late-Breaking News</A>
 
Value

Case-sensitive identifier.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].dataSrc
[window.]document.getElementById(elementID).dataSrc 
hrefNN all IE all HTML all  

href="URI"

Required for links  

The URI of the destination of a link. In browsers, when the URI is an HTML document, the document is loaded into the current (default) or other window target (as defined by the target attribute). For some other file types, the browser may load the destination content into a plugin or save the destination file on the client machine. In the absence of the href attribute, the element does not distinguish itself in a browser as a clickable link and may instead be only an anchor (if the name or id attribute is set).

 
Example
 
<A href="part1/chap3.html">Chapter 3</A>
 
Value

Any valid URI, including complete and relative URLs, anchors on the same page (anchor names prefaced with the # symbol), and the javascript: pseudo-URL in scriptable browsers to trigger a script statement rather than navigate to a destination.

 
Default

None.

 
Object Model Reference
 

In both browsers, other link object properties allow for the extraction of components of the URL, such as protocol and hostname. See the a element in Chapter 9.

[window.]document.links[i].href
[window.]document.getElementById(elementID).href
hreflangNN 6 IE 6 HTML 4  

hreflang="languageCode"

Optional  

The language code of the content at the destination of a link. Requires that the href attribute also be set. This attribute is primarily an advisory attribute to help a browser prepare itself for a new language set if the browser is so enabled.

 
Example
 
<A hreflang="HI" href="hindi/Chap3.html>Chapter 3 (in Hindi)</A>
 
Value

Case-insensitive language code.

 
Default

Browser default.

idNN 4 IE 4 HTML 4  

id="elementIdentifier"

Optional  

A unique identifier that distinguishes this element from all the rest in the document. Can be used to associate a single element with a style rule naming this attribute value as an ID selector. An element can have an ID assigned for uniqueness as well as a class for inclusion within a group. See Chapter 3.

IE 4 and later and Netscape 6 allow id attributes for nonrenderable elements, but if your code requires validation, be aware that the W3C HTML 4 and XHTML DTDs do not. Because all W3C DOM elements have an id property, it is natural to assign an id attribute to non-renderable elements if scripts must reference those elements. Or, your scripts may use other ways (e.g., the array returned by document.getElementsByTagName( )) to reference such elements.

Assign identifiers to id attributes in order to duplicate values previously only assigned to name attributes in elements that feature the name attribute. Current browser form controls still require name attributes for name/value pairs to be submitted with the form, and a elements acting as anchors still need name attributes. Be sure to assign an identifier to the id attribute of any element you intend to reference by script.

 
Example
 
<H2 id="sect3Head">Section Three</H2>
 
Value

Case-sensitive identifier.

 
Default

None.

 
Object Model Reference
 
[window.]document.getElementById(elementID).id
langNN 3 IE 4 HTML 4  

lang="languageCode"

Optional  

The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices.

 
Example
 
<SPAN lang="de">Deutsche Bundesbahn</SPAN>
 
Value

Case-insensitive language code.

 
Default

Browser default.

 
Object Model Reference
 
[window.]document.getElementById(elementID).lang
methodsNN n/a IE 4 HTML n/a  

methods="http-method"

Optional  

An advisory attribute about the functionality of the destination of a link. A browser could use this information to display special colors or images for the element content based on what the destination will do for the user.

 
Example
 
<A href="http://www.megacorp.com/cgi-bin/search?chap3" methods="get">
Chapter 3</A>
 
Value

Comma-delimited list of one or more HTTP methods.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].Methods
[window.]document.getElementById(elementID).Methods 
nameNN all IE all HTML all  

name="elementIdentifier"

Required for anchors  

The traditional way to signify an anchor position within a document. Other link elements can refer to the anchor by setting their href attributes to a URL ending in a pound sign (#) followed by the identifier. Omitting the name (and id) attribute for the a element prevents the element from being used as an anchor position. This attribute is interchangeable with the id attribute in recent browsers. The attribute is deprecated in XHTML 1.0, so you are encouraged to use both attributes (with the same identifier) to keep all browser generations happy. If the name and href attribute are set in the element, the element is considered both an anchor and a link.

 
Example
 
<A id="sect3" name="sect3">Section III</A>
 
Value

Case-sensitive identifier.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].name
[window.]document.anchors[i].name
[window.]document.getElementById(elementID).name
relNN 6 IE 3 HTML 4  

rel="linkTypes"

Optional  

Defines the relationship between the current element and the destination of the link. Also known as a forward link, not to be confused in any way with the destination document whose address is defined by the href attribute. The HTML 4 recommendation defines several link types; it is up to the browser to determine how to employ the value. This attribute has meaning primarily for the link element, although there is significant room for future application for tasks such as assigning an a element (acting as a link) to a button in a static navigation bar pointing to the next or previous document in a series. The element must include an href attribute for the rel attribute to be applied.

 
Example
 
<A rel="next chapter" href="chapter3.html">Chapter 3</A>
 
Value

Case-insensitive, space-delimited list of HTML 4 standard link types applicable to the element. Sanctioned link types are:

alternateappendixbookmarkchapter
contentscopyrightglossaryhelp
indexnextprevsection
startstylesheetsubsection

In addition, IE 3 defined a fixed set of four values: same | next | parent | previous, but only next and previous continue to be supported in IE.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].rel
[window.]document.getElementById(elementID).rel 
revNN 6 IE 3 HTML 4  

rev="linkTypes"

Optional  

A reverse link relationship. Like the rel attribute, the rev attribute's capabilities are defined by the browser, particularly with regard to how the browser interprets and renders the various link types available in the HTML 4 specification. Given two documents (A and B) containing links that point to each other, the rev value of B is designed to express the same relationship between the two documents as denoted by the rel attribute in A. There is not yet much application of either the rel or rev attributes of the a element in mainstream browsers.

 
Example
 
<A rev="previous" href="chapter2.html">Chapter 2</A>
 
Value

Case-insensitive, space-delimited list of standard link types applicable to the element. See the rel attribute for sanctioned and supported link types.

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].rev
[window.]document.getElementById(elementID).rev 
shapeNN n/a IE n/a HTML 4  

shape="shape"

Optional  

Defines the shape of a server-side image map area whose coordinates are specified with the coords attribute. See the area element.

tabindexNN 6 IE 4 HTML 4  

tabindex="integer"

Optional  

A number that indicates the sequence of this element within the tabbing order of all focusable elements in the document. Tabbing order follows a strict set of rules. Elements that have values other than zero assigned to their tabindex attributes are first in line when a user starts tabbing in a page. Focus starts with the element with the lowest tabindex value and proceeds in order to the highest value, regardless of physical location on the page or in the document. If two elements have the same tabindex values, the element that comes earlier in the document receives focus first. Next come all elements that either don't support the tabindex attribute or have the value set to zero. These elements receive focus in the order in which they appear in the document. Note that reloading the current page does not necessarily restart the tabbing sequence from the "top." Therefore, controlling tabbing sequence is most helpful when the logic of your focusable elements is something other than the source code order of those elements (e.g., directing tabbing to fields down table columns rather than across rows).

HTML 4 and Netscape 6 limit the tabindex attribute to the following elements: a, area, button, input, object, select, textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, span, table, and td. IE 5 adds every other renderable element. A negative value in IE (only) removes an element from tabbing order entirely.

Links and anchors cannot be tabbed to with the Mac version of IE 4, so the tabindex for a elements is ignored in that version.

 
Example
 
<A href="chapter3.html" tabindex="3">Chapter 3</A>
 
Value

Any integer from 0 through 32,767. In IE, setting tabindex to a negative value causes the element to be skipped in tabbing order altogether.

 
Default

None.

 
Object Model Reference
 
[window.]document.getElementById(elementID).tabIndex
targetNN all IE all HTML all  

target="windowOrFrameName"

Optional  

If the destination document is to be loaded into a window or frame other than the current window or frame, you can specify where the destination document should load by assigning a window or frame name to the target attribute. Target frame names must be assigned to frames and windows as identifiers. Assign names to frames via the name and id attributes of the frame element; assign names to new windows via the second parameter of the window.open( ) scripting method. If you omit this attribute, the destination document replaces the document containing the link. An identifier other than one belonging to an existing frame or window opens a new window for the destination document. This attribute is applicable only when a value is assigned to the href attribute of the element.

A link element can have only one destination document and one target. If you want a link to change the content of multiple frames, you can use an a element's onclick event handler or a javascript: pseudo-URL to fire a script that loads multiple documents. Set the location.href property of each frame to a desired URL.

Strict DTDs for HTML 4 and XHTML do not support the target attribute of any element because frames and windows are outside the scope of pure document markup. In fact, framesetting documents will not validate in the strict environmentthus the purpose of the separate frameset DTDs for HTML 4 and XHTML. If your documents must validate with these strict DTDs, and you wish to support targets, use scripts to set target properties of links, image maps, and forms after the page has loaded.

 
Example
 
<A target="display" href="chap3.html#sec2">Section 3.2</A>
<A target="_top" href="index.html">Start Over</A>
 
Value

Case-sensitive identifier when the frame or window name has been assigned via the target element's name and id attributes. Four reserved target names act as constants:

 
Default

_self

 
Object Model Reference
 
[window.]document.links[i].target
[window.]document.getElementById(elementID).target
typeNN 6 IE 6 HTML 4  

type="MIMEType"

Optional  

An advisory about the content type of the destination document or resource. A browser might use this information to assist in preparing support for a resource requiring a multimedia player or plugin.

 
Example
 
<A type="video/mpeg" href="ski4.mpeg">View Devil's Ghost slope</A>
 
Value

Case-insensitive MIME type. A catalog of registered MIME types is available from ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/.

 
Default

None.

urnNN n/a IE 4 HTML n/a  

urn="urn"

Optional  

A Uniform Resource Name version of the destination document specified in the href attribute. This attribute is intended to offer support in the future for the URN format of URI, an evolving recommendation under discussion at the IETF (see RFC 2141). Although supported in IE 4 and later, this attribute does not take the place of the href attribute.

 
Example
 
<A urn="urn:foo:bar3" href="chapter3.html">Chapter 3</A>
 
Value

A valid URN in the form of "urn:NamespaceID:NamespaceSpecificString".

 
Default

None.

 
Object Model Reference
 
[window.]document.links[i].urn
[window.]document.getElementById(elementID).urn