<a>

  • Revision slug: HTML/Element/a
  • Revision title: a
  • Revision id: 21820
  • Created:
  • Creator: pamelafox
  • Is current revision? No
  • Comment 6 words added

Revision Content

Summary

The HTML Anchor Element (<a>) defines a hyperlink, the named target destination for a hyperlink, or both.

Usage Context

Permitted content Transparent, containing either flow content or phrasing content.
Tag omission None, must have both a start tag and an end tag
Permitted parent elements Any element that accepts phrasing content, or any element that accepts flow content.
Normative document HTML 5, section 4.6.1; HTML 4.01, section 12.2

Attributes

Like all other HTML elements, this element has the global attributes.

{{ htmlattrdef("charset") }} {{ obsoleteGeneric("inline","HTML5") }}
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.

Usage note: This attribute is obsolete in HTML5 and should not be used by authors. To achieve its effect, use the HTTP Content-Type header on the linked resource.

{{ htmlattrdef("coords") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}
For use with object shapes, this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page.
{{ htmlattrdef("datafld") }} {{ Non-standard_inline() }}
This attribute specifies the column name from that data source object that supplies the bound data.

Usage note: This attribute is non-standard and should not be used by authors. To achieve its effect, use scripting and a mechanism such as XMLHttpRequest to populate the page dynamically

Support Gecko Presto WebKit Trident
Not implemented Not implemented Not implemented IE4, IE5, IE6, IE7 (Removed in IE8)
Normative document Microsoft's Data Binding: dataFld Property (MSDN)
{{ htmlattrdef("datasrc") }} {{ Non-standard_inline() }}
This attribute indicates the ID of the data source object that supplies the data that is bound to this element.

Usage note: This attribute is non-standard and should not be used by authors. To achieve its effect, use scripting and a mechanism such as XMLHttpRequest to populate the page dynamically.

Support Gecko Presto WebKit Trident
Not implemented Not implemented Not implemented IE4, IE5, IE6, IE7 (Removed in IE8)
Normative document Microsoft's Data Binding: dataSrc Property (MSDN)
{{ htmlattrdef("download") }} {{ HTMLVersionInline("5") }}
This attribute, if present, indicates that the author intends the hyperlink to be used for downloading a resource. If the attribute has a value, the browser should interpret that as the default filename that the author recommends for use in labeling the resource in a local file system. There are no restrictions on allowed values, but you should consider that most file systems have limitations with regard to what punctuation is supported in file names, and browsers are likely to adjust file names accordingly.

Note: This attribute can be used to make it easy for users to download programmatically generated data:, blob: and filesystem: URLs.

{{ htmlattrdef("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 (an ID) 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.

Note: You can use the special fragment "top" to create a link back to the top of the page; for example <a href="#top">Return to top</a>. This behavior is specified by HTML5.

{{ htmlattrdef("hreflang") }}
This attribute indicates the language of the linked resource. It is purely advisory Allowed values are determined by BCP47 for HTML5 and by RFC1766 for HTML4. Use this attribute only if the {{ htmlattrxref("href", "a") }} attribute is present.
{{ htmlattrdef("media") }} {{ HTMLVersionInline("5") }}
This attribute specifies the media which the linked resource applies to. Its value must be a media query. This attribute is mainly useful when linking to external stylesheets by allowing the user agent to pick the best adapted one for the device it runs on.

Usage note:

  • In HTML 4, only simple white-space-separated list of media description literals, i.e. media types and groups, where defined and allowed as values for this attribute, like print, screen, aural, braille, ... HTML 5 extended this to any kind of media queries, which are a superset of the allowed values of HTML 4.
  • Browsers not supporting the CSS3 Media Queries won't necessarilly recognize the adequate link; do not forget to set fallback links, the restricted set of media queries defined in HTML 4.
{{ htmlattrdef("methods") }} {{ Non-standard_inline() }}
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 attribute is not well understood nor supported, even by the defining browser, Internet Explorer 4. Methods Property (MSDN)
{{ htmlattrdef("name") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}
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.

Usage note:  This attribute is obsolete in HTML5, use global attribute id instead.

{{ htmlattrdef("ping") }} {{ HTMLVersionInline("5") }}
The support for "ping" was disabled starting with Firefox 3 beta 3. {{ Bug("415168") }}
{{ htmlattrdef("rel") }}
For anchors containing the href attribute, this attribute specifies the relationship of the target object to the link object. The value is a space-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. Use this attribute only if the href attribute is present.
{{ htmlattrdef("rev") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}
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.
Note: It is advisable to use the usemap attribute for the {{ HTMLElement("img") }} element and the associated {{ HTMLElement("map") }} element to define hotspots instead of the shape attribute.
{{ htmlattrdef("shape") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}
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 defines 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.
{{ htmlattrdef("target") }}
This attribute specifies where to display the linked resource. In HTML4, this is the name of, or a keyword for, a frame. In HTML5, it is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). The following keywords have special meanings:
  • _self: Load the response into the same HTML4 frame (or HTML5 browsing context) as the current one. This value is the default if the attribute is not specified.
  • _blank: Load the response into a new unnamed HTML4 window or HTML5 browsing context.
  • _parent: Load the response into the HTML4 frameset parent of the current frame or HTML5 parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: In HTML4: Load the response into the full, original window, canceling all other frames. In HTML5: Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.
Use this attribute only if the href attribute is present.
{{ htmlattrdef("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. Use this attribute only if the href attribute is present.
{{ htmlattrdef("urn") }} {{ Non-standard_inline() }}
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)

DOM Interface

This element implements the HTMLAnchorElement interface.

Example

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

Result

External Link

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatGeckoDesktop("1.0") }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
href="#top" {{ CompatVersionUnknown() }} {{ CompatGeckoDesktop("10.0") }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatVersionUnknown() }} {{ CompatGeckoMobile("1.0") }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
href="#top" {{ CompatVersionUnknown() }} {{ CompatGeckoMobile("10.0") }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}

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.

JavaScript recommendations

It is often the case that an anchor tag is used with the onclick event. In order to prevent the page from refreshing, href is often set to either "#" or "javascript:void(0)". Both of these values can lead to some unexpected errors when copying links and opening links in a new tab and/or window. Be aware of this for usability reasons, and when users do use anchor tags and you prevent default behavior.

{{ 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

<h2>Summary</h2>
<p>The HTML Anchor Element (<code>&lt;a&gt;</code>) defines a hyperlink, the named target destination for a hyperlink, or both.</p>
<h2>Usage Context</h2>
<table class="standard-table"> <tbody> <tr> <td>Permitted content</td> <td><a href="/en/HTML/Content_categories#Transparent_content_model" title="https://developer.mozilla.org/en/HTML/Content_categories#Transparent_content_model">Transparent</a>, containing either <a href="/en/HTML/Content_categories#Flow_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Flow_content">flow content</a> or <a href="/en/HTML/Content_categories#Phrasing_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td> </tr> <tr> <td>Tag omission</td> <td>None, must have both a start tag and an end tag</td> </tr> <tr> <td>Permitted parent elements</td> <td>Any element that accepts <a href="/en/HTML/Content_categories#Phrasing_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Phrasing_content">phrasing content</a>, or any element that accepts <a href="/en/HTML/Content_categories#Flow_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Flow_content">flow content</a>.</td> </tr> <tr> <td>Normative document</td> <td><a class="external" href="http://www.w3.org/TR/html5/text-level-semantics.html#the-a-element" title="http://www.w3.org/TR/html5/text-level-semantics.html#the-a-element">HTML 5, section 4.6.1</a>; <a class="external" href="http://www.w3.org/TR/html401/struct/links.html#h-12.2" title="http://www.w3.org/TR/html401/struct/links.html#h-12.2">HTML 4.01, section 12.2</a></td> </tr> </tbody>
</table>
<h2>Attributes</h2>
<p>Like all other HTML elements, this element has the <a href="/en/HTML/Global_attributes" title="en/HTML/Global attributes">global attributes</a>.</p>
<dl> <dt>{{ htmlattrdef("charset") }} {{ obsoleteGeneric("inline","HTML5") }}</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. <div class="note"> <p><strong>Usage note: </strong>This attribute is obsolete in HTML5 and <strong>should not be used by authors</strong>. To achieve its effect, use the HTTP Content-Type header on the linked resource.</p> </div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("coords") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}</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>{{ htmlattrdef("datafld") }} {{ Non-standard_inline() }}</dt> <dd>This attribute specifies the column name from that data source object that supplies the bound data. <div class="note"> <p><strong>Usage note: </strong>This attribute is non-standard and <strong>should not be used by authors</strong>. To achieve its effect, use scripting and a mechanism such as <a href="/en/nsIXMLHttpRequest" title="en/XMLHttpRequest">XMLHttpRequest</a> to populate the page dynamically</p> </div> <table class="fullwidth-table"> <tbody> <tr> <td rowspan="2">Support</td> <td>Gecko</td> <td>Presto</td> <td>WebKit</td> <td>Trident</td> </tr> <tr> <td>Not implemented</td> <td>Not implemented</td> <td>Not implemented</td> <td>IE4, IE5, IE6, IE7 (Removed in IE8)</td> </tr> <tr> <td>Normative document</td> <td colspan="4"><a class="external" href="http://msdn.microsoft.com/en-us/library/ms533703%28VS.85%29.aspx">Microsoft's Data Binding: dataFld Property (MSDN)</a></td> </tr> </tbody> </table> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("datasrc") }} {{ Non-standard_inline() }}</dt> <dd>This attribute indicates the ID of the data source object that supplies the data that is bound to this element. <div class="note"> <p><strong>Usage note: </strong>This attribute is non-standard and <strong>should not be used by authors</strong>. To achieve its effect, use scripting and a mechanism such as <a href="/en/nsIXMLHttpRequest" title="en/XMLHttpRequest">XMLHttpRequest</a> to populate the page dynamically.</p> </div> <table class="fullwidth-table"> <tbody> <tr> <td rowspan="2">Support</td> <td>Gecko</td> <td>Presto</td> <td>WebKit</td> <td>Trident</td> </tr> <tr> <td>Not implemented</td> <td>Not implemented</td> <td>Not implemented</td> <td>IE4, IE5, IE6, IE7 (Removed in IE8)</td> </tr> <tr> <td>Normative document</td> <td colspan="4"><a class="external" href="http://msdn.microsoft.com/en-us/library/ms533709(VS.85).aspx" title="http://msdn.microsoft.com/en-us/library/ms533709(VS.85).aspx">Microsoft's Data Binding: dataSrc Property (MSDN)</a></td> </tr> </tbody> </table> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("download") }} {{ HTMLVersionInline("5") }}</dt> <dd>This attribute, if present, indicates that the author intends the hyperlink to be used for downloading a resource. If the attribute has a value, the browser should interpret that as the default filename that the author recommends for use in labeling the resource in a local file system. There are no restrictions on allowed values, but you should consider that most file systems have limitations with regard to what punctuation is supported in file names, and browsers are likely to adjust file names accordingly. <div class="note"> <p><strong>Note:</strong> This attribute can be used to make it easy for users to download programmatically generated <code>data:</code>, <code>blob:</code> and <code>filesystem:</code> URLs.</p> </div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("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 (an <a href="/en/HTML/Global_attributes#attr-id" title="../../Global attributes#attr-id">ID</a>) within the current document. URLs are not restricted to Web (HTTP)-based documents. URLs might use any protocol supported by the browser. For example, <code>file</code>, <code>ftp</code>, and <code>mailto</code> work in most user agents. <div class="note"> <p><strong>Note:</strong> You can use the special fragment "top" to create a link back to the top of the page; for example <code>&lt;a href="#top"&gt;Return to top&lt;/a&gt;</code>. This behavior is specified by HTML5.</p> </div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("hreflang") }}</dt> <dd>This attribute indicates the language of the linked resource. It is purely advisory Allowed values are determined by <a class="external" href="http://www.ietf.org/rfc/bcp/bcp47.txt" title="http://www.ietf.org/rfc/bcp/bcp47.txt">BCP47</a> for HTML5 and by <a class="external" href="http://www.ietf.org/rfc/rfc1766.txt" title="http://www.ietf.org/rfc/rfc1766.txt">RFC1766</a> for HTML4. Use this attribute only if the {{ htmlattrxref("href", "a") }} attribute is present.</dd> <dt>{{ htmlattrdef("media") }} {{ HTMLVersionInline("5") }}</dt> <dd>This attribute specifies the media which the linked resource applies to. Its value must be a <a href="/en/CSS/Media_queries" title="En/CSS/Media queries">media query</a>. This attribute is mainly useful when linking to external stylesheets by allowing the user agent to pick the best adapted one for the device it runs on.<br> <div class="note"> <p><strong>Usage note:</strong></p> <ul> <li>In HTML 4, only simple white-space-separated list of media description literals, i.e. <a href="/en/CSS/@media" title="https://developer.mozilla.org/en/CSS/@media">media types and groups</a>, where defined and allowed as values for this attribute, like <span style="font-family: Courier New;">print</span>, <span style="font-family: Courier New;">screen</span>, <span style="font-family: Courier New;">aural</span>, <span style="font-family: Courier New;">braille</span>, ... HTML 5 extended this to any kind of <a href="/en/CSS/Media_queries" title="En/CSS/Media queries">media queries</a>, which are a superset of the allowed values of HTML 4.</li> <li>Browsers not supporting the <a href="/en/CSS/Media_queries" title="En/CSS/Media queries">CSS3 Media Queries</a> won't necessarilly recognize the adequate link; do not forget to set fallback links, the restricted set of media queries defined in HTML 4.</li> </ul> </div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("methods") }} {{ Non-standard_inline() }}</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 attribute 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> <dt>{{ htmlattrdef("name") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}</dt> <dd>This attribute is required in an anchor defining a target location within a page. A value for <strong>name</strong> is similar to a value for the <strong>id</strong> core attribute and should be an alphanumeric identifier unique to the document. Under the HTML 4.01 specification, <strong>id</strong> and <strong>name</strong> both can be used with the &lt;a&gt; element as long as they have identical values. <div class="note"> <p><strong>Usage note: </strong> This attribute is obsolete in HTML5, use <a href="/en/HTML/Global_attributes#id" title="en/HTML/Global attributes#id">global attribute <strong>id</strong></a> instead.</p> </div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("ping") }} {{ HTMLVersionInline("5") }}</dt> <dd>The support for "ping" was disabled starting with Firefox 3 beta 3. {{ Bug("415168") }}</dd>
</dl>
<dl> <dt>{{ htmlattrdef("rel") }}</dt> <dd>For anchors containing the <strong>href</strong> attribute, this attribute specifies the relationship of the target object to the link object. The value is a space-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. Use this attribute only if the <strong>href</strong> attribute is present.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("rev") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}</dt> <dd>This attribute specifies a reverse link, the inverse relationship of the <strong>rel</strong> attribute. It is useful for indicating where an object came from, such as the author of a document.</dd>
</dl>
<div class="note"><em>Note</em>: It is advisable to use the <strong>usemap</strong> attribute for the {{ HTMLElement("img") }} element and the associated {{ HTMLElement("map") }} element to define hotspots instead of the <strong>shape</strong> attribute.</div>
<dl> <dt>{{ htmlattrdef("shape") }} {{ HTMLVersionInline("4") }} only, {{ obsoleteGeneric("inline","HTML5") }}</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 <code>circle</code>, <code>default</code>, <code>polygon</code>, and <code>rect</code>. The format of the <strong>coords</strong> attribute depends on the value of shape. For <code>circle</code>, the value is <code>x,y,r</code> where <code>x</code> and <code>y</code> are the pixel coordinates for the center of the circle and <code>r</code> is the radius value in pixels. For <code>rect</code>, the <strong>coords</strong> attribute should be <code>x,y,w,h</code>. The <code>x,y</code> values define the upper-left-hand corner of the rectangle, while <code>w</code> and <code>h</code> define the width and height respectively. A value of <code>polygon</code> for <strong>shape</strong> requires <code>x1,y1,x2,y2,...</code> values for <strong>coords</strong>. Each of the <code>x,y</code> pairs defines a point in the polygon, with successive points being joined by straight lines and the last point joined to the first. The value <code>default</code> for shape requires that the entire enclosed area, typically an image, be used.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("target") }}</dt> <dd>This attribute specifies where to display the linked resource. In HTML4, this is the name of, or a keyword for, a frame. In HTML5, it is a name of, or keyword for, a <em>browsing context</em> (for example, tab, window, or inline frame). The following keywords have special meanings: <ul> <li><span style="font-family: Courier New;">_self</span>: Load the response into the same HTML4 frame (or HTML5 browsing context) as the current one. This value is the default if the attribute is not specified.</li> <li><span style="font-family: Courier New;">_blank</span>: Load the response into a new unnamed HTML4 window or HTML5 browsing context.</li> <li><span style="font-family: Courier New;">_parent</span>: Load the response into the HTML4 frameset parent of the current frame or HTML5 parent browsing context of the current one. If there is no parent, this option behaves the same way as <span style="font-family: Courier New;">_self</span>.</li> <li><span style="font-family: Courier New;">_top</span>: In HTML4: Load the response into the full, original window, canceling all other frames. In HTML5: Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as <span style="font-family: Courier New;">_self</span>.</li> </ul> Use this attribute only if the <strong>href</strong> attribute is present.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("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="linkification-ext external" href="http://www.w3.org/TR/html4/references.html#ref-MIMETYPES" title="Linkification: http://www.w3.org/TR/html4/references.html#ref-MIMETYPES">http://www.w3.org/TR/html4/references.html#ref-MIMETYPES</a>. Use this attribute only if the <strong>href</strong> attribute is present.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("urn") }} {{ Non-standard_inline() }}</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>
<h2>DOM Interface</h2>
<p>This element implements the <code><a href="/en/DOM/HTMLAnchorElement" title="en/DOM/HTMLAnchorElement">HTMLAnchorElement</a></code> interface.</p>
<h2>Example</h2>
<pre class="brush: html">&lt;!-- anchor linking to external file --&gt;
&lt;a href="<a class="linkification-ext" href="http://www.mozilla.com/" title="Linkification: http://www.mozilla.com/">http://www.mozilla.com/</a>"&gt;
External Link
&lt;/a&gt;
</pre>
<h3 name="Result">Result</h3>
<!-- anchor linking to external file --><p><a class="external" href="http://www.mozilla.com/">External Link</a></p>
<h2>Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatGeckoDesktop("1.0") }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> <tr> <td><code>href="#top"</code></td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatGeckoDesktop("10.0") }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatGeckoMobile("1.0") }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> <tr> <td><code>href="#top"</code></td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatGeckoMobile("10.0") }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> </tbody> </table>
</div>
<h2>Notes</h2>
<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 <strong>name</strong>, <strong>href</strong>, <strong>rel</strong>, <strong>rev</strong>, and <strong>title</strong>.</p>
<p>The <strong>target</strong> 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" title="en/XHTML">XHTML</a> but is limited to frameset or transitional forms.</p>
<h3>JavaScript recommendations</h3>
<p>It is often the case that an anchor tag is used with the <code>onclick</code> event. In order to prevent the page from refreshing, <strong>href </strong>is often set to either "#" or "javascript:void(0)". Both of these values can lead to some unexpected errors when copying links and opening links in a new tab and/or window. Be aware of this for usability reasons, and when users do use anchor tags and you prevent default behavior.</p>
<p>{{ HTML:Element_Navigation() }}</p>
<p>{{ languages( { "es": "es/HTML/Element/a", "fr": "fr/HTML/Element/a", "ja": "ja/HTML/Element/a", "pl": "pl/HTML/Element/a" } ) }}</p>
Revert to this revision