<a>

  • Revision slug: HTML/Element/a
  • Revision title: a
  • Revision id: 21780
  • Created:
  • Creator: Gaspard.leon
  • Is current revision? No
  • Comment /* Attributes */ Add links to MSDN pages for IE specific stuff

Revision Content


Summary

The anchor (<a>) element defines a hyperlink, the named target destination for a hyperlink, or both.

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. dataFld Property (MSDN)
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. dataSrc Property (MSDN)
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. Methods Property (MSDN)
ping {{ Fx_minversion_inline("3") }}
If present, this attribute should be a space-separated list of URIs that wish to be notified when the user follows the hyperlink. Firefox sends a POST request to each HTTP URI in the list. The ping attribute's functionality can be enabled by setting the browser.send_pings preference to true. The support for "ping" was disabled starting with Firefox 3 beta 3 ({{ Bug("415168") }}).
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.

Note: It is advisable to use the usemap attribute for the img element and the associated map element to define hotspots instead of the shape attribute.

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/reference...#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. urn Property (MSDN)

Example

    <!-- anchor linking to external file -->
    <a href="http://www.mozilla.com/">
    External Link
    </a>

Result

External Link

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. Furthermore, target is not allowed under strict variants of XHTML but is limited to frameset or transitional forms.

{{ HTML:Element_Navigation() }}



{{ languages( { "es": "es/HTML/Element/a", "fr": "fr/HTML/Element/a", "ja": "ja/HTML/Element/a", "pl": "pl/HTML/Element/a" } ) }}

Revision Source

<p><br>
</p>
<h3 name="Summary"> Summary </h3>
<p>The <i>anchor</i> (<code>&lt;a&gt;</code>) element defines a hyperlink, the named target destination for a hyperlink, or both.
</p>
<h3 name="Attributes"> Attributes </h3>
<dl><dt>accesskey
</dt><dd>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.
</dd></dl>
<dl><dt>charset
</dt><dd>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 <a class="external" href="http://tools.ietf.org/html/rfc2045" title="http://tools.ietf.org/html/rfc2045">RFC 2045</a>. The default value is ISO-8859-1.
</dd></dl>
<dl><dt>coords
</dt><dd>For use with object shapes, this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page.
</dd></dl>
<dl><dt>datafld
</dt><dd>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. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms533703(VS.85).aspx">dataFld Property (MSDN)</a>
</dd></dl>
<dl><dt>datasrc
</dt><dd>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. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms533709(VS.85).aspx">dataSrc Property (MSDN)</a>
</dd></dl>
<dl><dt>href
</dt><dd>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.
</dd></dl>
<dl><dt>hreflang
</dt><dd>This attribute is used to indicate the language of the linked resource. See "Language Reference," earlier in this appendix for information on allowed values.
</dd></dl>
<dl><dt>methods
</dt><dd>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. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms534168(VS.85).aspx">Methods Property (MSDN)</a>
</dd></dl>
<dl><dt>ping {{ Fx_minversion_inline("3") }}
</dt><dd><strike>If present, this attribute should be a space-separated list of URIs that wish to be notified when the user follows the hyperlink. Firefox sends a POST request to each HTTP URI in the list. The <code>ping</code> attribute's functionality can be enabled by setting the <code>browser.send_pings</code> preference to <code>true</code>.</strike> The support for "ping" was disabled starting with Firefox 3 beta 3 ({{ Bug("415168") }}).
</dd></dl>
<dl><dt>name
</dt><dd>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 &lt;a&gt; element as long as they have identical values.
</dd></dl>
<dl><dt>rel
</dt><dd>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.
</dd></dl>
<dl><dt>rev
</dt><dd>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.
</dd></dl>
<dl><dt>shape
</dt><dd>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.
</dd></dl>
<p><i>Note</i>: It is advisable to use the usemap attribute for the img element and the associated map element to define hotspots instead of the shape attribute.
</p>
<dl><dt>tabindex
</dt><dd>This attribute uses a number to identify the object's position in the tabbing order for keyboard navigation using the TAB key.
</dd></dl>
<dl><dt>target
</dt><dd>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.
</dd></dl>
<dl><dt>type
</dt><dd>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 <a class=" external" href="http://www.w3.org/TR/html4/references.html#ref-MIMETYPES" rel="freelink">http://www.w3.org/TR/html4/reference...#ref-MIMETYPES</a>.
</dd></dl>
<dl><dt>urn
</dt><dd>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. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms534710(VS.85).aspx">urn Property (MSDN)</a>
</dd></dl>
<h3 name="Example"> Example </h3>
<pre>    &lt;!-- anchor linking to external file --&gt;
    &lt;a href="http://www.mozilla.com/"&gt;
    External Link
    &lt;/a&gt;
</pre>
<h4 name="Result"> Result </h4>
<p><a class="external" href="http://www.mozilla.com/">External Link</a>
</p>
<h3 name="Notes"> Notes </h3>
<p>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.
</p><p>HTML 3.2 defines only <b>name</b>, <b>href</b>, <b>rel</b>, <b>rev</b>, and <b>title</b>.
</p><p>The <b>target</b> 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 <a href="en/XHTML">XHTML</a> but is limited to frameset or transitional forms.
</p><p>{{ HTML:Element_Navigation() }}
</p><p><br>
</p><p><br>
</p>
<div class="noinclude">
</div>
{{ languages( { "es": "es/HTML/Element/a", "fr": "fr/HTML/Element/a", "ja": "ja/HTML/Element/a", "pl": "pl/HTML/Element/a" } ) }}
Revert to this revision