<a> (Anchor)
This element defines a hyperlink, the named target destination for a hyperlink, or both.
Standard Syntax
<a
accesskey="key"</a>
charset="character code for language of linked resource"
class="class name(s)"
coords="comma-separated list of numbers"
dir="ltr | rtl"
href="url"
hreflang="language code"
id="unique alphanumeric identifier"
lang="language code"
name="name of target location"
rel="comma-separated list of relationship values"
rev="comma-separated list of relationship values"
shape="default | circle | poly | rect"
style="style information"
tabindex="number"
target="_blank | frame-name | _parent | _self |
_top" (transitional)
title="advisory text"
type="content type of linked data"
Attributes Defined by Internet Explorer
contenteditable="false | true | inherit" (5.5)
datafield="name of column supplying bound data" (4)
datasrc="ID of data source object supplying data" (4)
disabled="false | true" (5.5)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
methods="http-method" (4)
unselectable="off | on" (5.5)
urn="URN string" (4)
Standard Events
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
Events Defined by Internet Explorer
onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onselectstart, ontimeerror
Element Specific Attributes
- accesskey
- This attribute specifies a keyboard navigation accelerator for the element. Pressing ALT or a similar key (depending on the browser and operating system) in association with the specified key selects the anchor element correlated with that key.
- charset
- This attribute defines the character encoding of the linked resource. The value is a space- and/or comma-delimited list of character sets as defined in RFC 2045. The default value is ISO-8859-1.
- coords
- For use with object shapes, this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page.
- datafld
- This attribute specifies the column name from that data source object that supplies the bound data. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4.
- datasrc
- This attribute indicates the id of the data source object that supplies the data that is bound to this element. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4.
- href
- This is the single required attribute for anchors defining a hypertext source link. It indicates the link target, either a URL or a URL fragment, that is a name preceded by a hash mark (#), which specifies an internal target location within the current document. URLs are not restricted to Web (http)-based documents. URLs might use any protocol supported by the browser. For example, file, ftp, and mailto work in most user agents.
- hreflang
- This attribute is used to indicate the language of the linked resource. See "Language Reference," earlier in this appendix for information on allowed values.
- methods
- The value of this attribute provides information about the functions that might be performed on an object. The values generally are given by the HTTP protocol when it is used, but it might (for similar reasons as for the title attribute) be useful to include advisory information in advance in the link. For example, the browser might choose a different rendering of a link as a function of the methods specified; something that is searchable might get a different icon, or an outside link might render with an indication of leaving the current site. This element is not well understood nor supported, even by the defining browser, Internet Explorer 4.
- name
- This attribute is required in an anchor defining a target location within a page. A value for name is similar to a value for the id core attribute and should be an alphanumeric identifier unique to the document. Under the HTML 4.01 specification, id and name both can be used with the <a> element as long as they have identical values.
- rel
- For anchors containing the href attribute, this attribute specifies the relationship of the target object to the link object. The value is a comma-separated list of relationship values. The values and their semantics will be registered by some authority that might have meaning to the document author. The default relationship, if no other is given, is void. The rel attribute should be used only when the href attribute is present.
- rev
- This attribute specifies a reverse link, the inverse relationship of the rel attribute. It is useful for indicating where an object came from, such as the author of a document.
- shape
- This attribute is used to define a selectable region for hypertext source links associated with a figure to create an image map. The values for the attribute are circle, default, polygon, and rect. The format of the coords attribute depends on the value of shape. For circle, the value is x,y,r where x and y are the pixel coordinates for the center of the circle and r is the radius value in pixels. For rect, the coords attribute should be x,y,w,h. The x,y values define the upper-left-hand corner of the rectangle, while w and h define the width and height respectively. A value of polygon for shape requires x1,y1,x2,y2,... values for coords. Each of the x,y pairs define a point in the polygon, with successive points being joined by straight lines and the last point joined to the first. The value default for shape requires that the entire enclosed area, typically an image, be used.
- tabindex
- This attribute uses a number to identify the object's position in the tabbing order for keyboard navigation using the TAB key.
- target
- This attribute specifies the target window for a hypertext source link that references frames. The information linked to target will be displayed in the named window. Frames and inline frames must be named to be targeted. There are, however, special name values. These include _blank, which indicates a new window; _parent, which indicates the parent frame set containing the source link; _self, which indicates the frame containing the source link; and _top, which indicates the full browser window.
- type
- This attribute specifies the media type in the form of a MIME type for the link target. Generally, this is provided strictly as advisory information; however, in the future a browser might add a small icon for multimedia types. For example, a browser might add a small speaker icon when type is set to audio/wav. For a complete list of recognized MIME types, see http://www.w3.org/TR/html4/references.html#ref-MIMETYPES.
- urn
- This supposedly Microsoft-supported attribute relates a uniform resource name (URN) with the link. While it is based on standards work years back, the meaning of URNs is still not well defined, so this attribute is meaningless.
Examples
<!-- anchor linking to external file -->
<a href="http://www.democompany.com/">
External Link
</a>
<!-- anchor linking to file on local filesystem -->
<a href="file:/c:\html\index.htm">
local file link
</a>
<!-- anchor invoking anonymous FTP -->
<a href="ftp://ftp.democompany.com/freestuff">
Anonymous FTP link
</a>
<!-- anchor invoking FTP with password -->
<a href=
"ftp://user:secretpassword@
democompany.com/path/file">
FTP with password</a>
<!-- anchor invoking mail -->
<a href="mailto:fakeid@democompany.com">
Send mail
</a>
<!-- anchor used to define target destination within document -->
<a name="jump">
Jump target
</a>
<!-- anchor linking internally to previous target anchor -->
<a href="#jump">Local jump within document</a>
<!-- anchor linking externally
to previous target anchor -->
<a href="http://www.democompany.com/
document#jump">
Remote jump within document
</a>
<a href="http://www.democompany.com/">
External Link
</a>
<!-- anchor linking to file on local filesystem -->
<a href="file:/c:\html\index.htm">
local file link
</a>
<!-- anchor invoking anonymous FTP -->
<a href="ftp://ftp.democompany.com/freestuff">
Anonymous FTP link
</a>
<!-- anchor invoking FTP with password -->
<a href=
"ftp://user:secretpassword@
democompany.com/path/file">
FTP with password</a>
<!-- anchor invoking mail -->
<a href="mailto:fakeid@democompany.com">
Send mail
</a>
<!-- anchor used to define target destination within document -->
<a name="jump">
Jump target
</a>
<!-- anchor linking internally to previous target anchor -->
<a href="#jump">Local jump within document</a>
<!-- anchor linking externally
to previous target anchor -->
<a href="http://www.democompany.com/
document#jump">
Remote jump within document
</a>
Compatibility
HTML 2, 3.2, 4, 4.01, and XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 1.1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7
Notes
The following are reserved browser key bindings for the two major browsers and should not be used as values to accesskey: a, c, e, f, g, h, v, left arrow, and right arrow.
HTML 3.2 defines only name, href, rel, rev, and title.
The target attribute is not defined in browsers that do not support frames, such as Netscape 1 generation browsers.
The target attribute is not defined in browsers that do not support frames, such as Netscape 1 generation browsers. Furthermore, target is not allowed under strict variants of XHTML but is limited to frameset or transitional forms.