Hubo un error de script en esta página. Mientras los editores del sitio lo solucionan, puedes ver una parte del contenido más abajo.

Esta traducción está incompleta. Por favor, ayuda a traducir este artículo del inglés.

El Elemento HTML Anchor (<a>) define un hiper vínculo a una ubicación en la misma página o cualquier otra página en la Web. También se puede utilizar (en una forma obsoleta) para crear un punto punto de anclaje—a un destino para los hiper vínculos dentro del contenido de una página, de modo que los enlaces no se limitan a conectar simplemente a la parte superior de una página.

<a href="">MDN</a>
Categorías de contenido Contenido de flujo, contenido de párrafo, contenido interactivo, contenido palpable
Contenido permitido Transparente, que contiene contenido de flujo (excluyendo contenido interactivo) o contenido de párrafo.
Omisión de etiquetas {{{no omisión de etiqueta}}
Elementos principales permitidos Cualquier elemento que acepte contenido de párrafo o cualquier elemento que acepte contenido de flujo.
Interfaz DOM {{domxref ( "Elemento de anclaje HTML")


This element includes the global attributes.

{{htmlattrdef("download")}} {{HTMLVersionInline(5)}}
Este atributo, si está presente, indica que el autor pretende que el hipervínculo se utilice para descargar un recurso, de modo que cuando el usuario haga clic en el enlace, se le pregunte si desea guardarlo como un archivo local. Si el atributo tiene un valor, el valor se utilizará como nombre de archivo por defecto en el mensaje Guardar que se abre cuando el usuario hace clic en el enlace (el usuario puede cambiar el nombre antes de guardar el archivo). No hay restricciones sobre los valores permitidos (aunque: / y: \ se convertirán en subrayados, lo que evitará sugerencias de ruta específicas), pero debe tener en cuenta que la mayoría de los sistemas de archivos tienen limitaciones con respecto a qué puntuación se admite en los nombres de archivo. Ajuste los nombres de los archivos en consecuencia.


  • Can be used with blob: URLs and data: URLs, to make it easy for users to download content that is generated programmatically using JavaScript (e.g. a picture created using an online drawing Web app).
  • If the HTTP header Content-Disposition: is present and gives a different filename than this attribute, the HTTP header has priority over this attribute.
  • If this attribute is present and Content-Disposition: is set to inline, Firefox gives priority to Content-Disposition, like for the filename case, while Chrome gives priority to the download attribute.
  • This attribute is only honored for links to resources with the same-origin.
This was the single required attribute for anchors defining a hypertext source link, but is no longer required in HTML5. Omitting this attribute creates a placeholder link. The href attribute indicates the link target, either a URL or a URL fragment. A URL fragment 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.

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("ping")}} {{HTMLVersionInline(5)}}
The 'ping' attribute, if present, sends the URLs of the resources a notification/ping if the user follows the hyperlink.
{{htmlattrdef("referrerpolicy")}} {{experimental_inline}}
A string indicating which referrer to use when fetching the resource:
  • 'no-referrer' meaning that the Referer: header will not be sent.
  • 'no-referrer-when-downgrade' meaning that no Referer: header will be sent when navigating to an origin without TLS (HTTPS). This is a user agent’s default behavior, if no policy is otherwise specified.
  • 'origin' meaning that the referrer will be the origin of the page, that is roughly the scheme, the host and the port.
  • 'origin-when-cross-origin' meaning that navigations to other origins will be limited to the scheme, the host and the port, while navigations on the same origin will include the referrer's path.
  • 'unsafe-url' meaning that the referrer will include the origin and the path (but not the fragment, password, or username). This case is unsafe because it can leak origins and paths from TLS-protected resources to insecure origins.
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 link types 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.
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.
This attribute specifies the media type in the form of a {{Glossary("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 Use this attribute only if the href attribute is present.


{{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("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("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.
{{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.
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.

Non standard

{{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("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("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)


Linking to an external location

<!-- anchor linking to external file -->
<a href="">
External Link


External Link

Creating a clickable image

This small example use an image to link to the MDN home page. The home page will open in a new browsing context, that is a new page or a new tab.

<a href="" target="_blank">
  <img src="" alt="MDN logo" />


{{EmbedLiveSample("Creating_a_clickable_image", "320", "64")}}

It's common to create buttons or links that will open in the user's email program to allow them to send a new message. This is done by using a mailto link. Here's a simple example:

<a href="">Send email to nowhere</a>

This results in a link that looks like this: Send email to nowhere.

For additional details about the mailto URL scheme, such as how to include the subject, body, or other predetermined content, see Email links or {{RFC(6068)}}.

With phones viewing web documents and laptops being connected to phones offering clickable phone links becomes increasingly helpful.

<a href="tel:+491570156">+49 157 0156</a>

For additional details about the tel URL scheme, see {{RFC(2806)}} and {{RFC(2396)}}.

Using the download attribute to save a canvas as a PNG

If you want to allow a user to download an HTML Canvas as an image you can create a link with a download attribute and the canvas data as a file URL:

var link = document.createElement('a');
link.innerHTML = 'download image';

link.addEventListener('click', function(ev) {
    link.href = canvas.toDataURL(); = "mypainting.png";
}, false);


You can see this in action


Specification Status Comment
{{SpecName('Referrer Policy', '#referrer-policy-delivery-referrer-attribute', 'referrer attribute')}} {{Spec2('Referrer Policy')}} Added the referrer attribute.
{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-a-element', '<a>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-a-element', '<a>')}} {{Spec2('HTML5 W3C')}}  
{{SpecName('HTML4.01', 'struct/links.html#h-12.2', '<a>')}} {{Spec2('HTML4.01')}}  

Browser compatibility


Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}} [1] {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
href="#top" {{CompatVersionUnknown}} {{CompatGeckoDesktop("10.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
download {{CompatChrome("14")}} {{CompatGeckoDesktop("20.0")}} Edge 13 [5] {{CompatOpera("15")}} {{CompatNo}}
ping {{CompatVersionUnknown}} {{CompatNo}} [2] {{CompatNo}} {{CompatVersionUnknown}} {{CompatNo}}
referrerpolicy {{CompatChrome(46.0)}} [3] {{CompatGeckoDesktop("45")}} [4] {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} [1] {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
href="#top" {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("10.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}}
download {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("20.0")}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}}
ping {{CompatUnknown}} {{CompatUnknown}} {{CompatNo}} [2] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
referrerpolicy {{CompatNo}} {{CompatChrome(46.0)}} [3] {{CompatGeckoMobile("45.0")}} [4] {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatChrome(46.0)}} [3]

[1] Starting from Gecko 41 {{geckoRelease("41.0")}}, {{HTMLElement("a")}} without href attribute is no more classified as interactive content. Clicking it inside {{HTMLElement("label")}} will activate labelled content ({{bug(1167816)}}).

[2] Disabled by default

[3] Implemented behind a flag.

[4] Behind the network.http.enablePerElementReferrer preference, that default to false. From Firefox 42 to Firefox 44, the attribute was called referrer.

[5] Attempting to download data URIs causes Edge to crash until v14.14357.

Clicking and focus

Whether clicking on an {{HTMLElement("a")}} causes it to (by default) become focused varies by browser and OS.

Does clicking on an {{HTMLElement("a")}} give it the focus?
Desktop Browsers Windows 8.1 OS X 10.9
Firefox 30.0 Yes Yes
Chrome ≥39
(Chromium bug 388666)
Yes Yes
Safari 7.0.5 N/A Only when it has a tabindex
Internet Explorer 11 Yes N/A
Presto (Opera 12) Yes Yes
Does tapping on an {{HTMLElement("a")}} give it the focus?
Mobile Browsers iOS 7.1.2 Android 4.4.4
Safari Mobile Only when it has a tabindex N/A
Chrome 35 ??? Only when it has a tabindex


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.

See also

  • Other elements conveying text-level semantics: {{HTMLElement("abbr")}}, {{HTMLElement("em")}}, {{HTMLElement("strong")}}, {{HTMLElement("small")}}, {{HTMLElement("cite")}}, {{HTMLElement("q")}}, {{HTMLElement("dfn")}}, {{HTMLElement("time")}}, {{HTMLElement("code")}}, {{HTMLElement("var")}}, {{HTMLElement("samp")}}, {{HTMLElement("kbd")}}, {{HTMLElement("sub")}}, {{HTMLElement("sup")}}, {{HTMLElement("b")}}, {{HTMLElement("i")}}, {{HTMLElement("mark")}}, {{HTMLElement("ruby")}}, {{HTMLElement("rp")}}, {{HTMLElement("rt")}}, {{HTMLElement("bdo")}}, {{HTMLElement("span")}}, {{HTMLElement("br")}}, {{HTMLElement("wbr")}}.

Etiquetas y colaboradores del documento

 Última actualización por: julioematasv,