This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The HTMLAnchorElement interface represents hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. This interface corresponds to <a> element; not to be confused with <link>, which is represented by HTMLLinkElement.
Inherits properties from its parent, HTMLElement.
HTMLAnchorElement.attributionSrc Secure context Experimental
Gets and sets the attributionsrc attribute on an <a> element programmatically, reflecting the value of that attribute. attributionsrc specifies that you want the browser to send an Attribution-Reporting-Eligible header. On the server-side this is used to trigger sending an Attribution-Reporting-Register-Source header in the response, to register a navigation-based attribution source.
HTMLAnchorElement.downloadA string indicating that the linked resource is intended to be downloaded rather than displayed in the browser. The value represents the proposed name of the file. If the name is not a valid filename of the underlying OS, the browser will adapt it.
HTMLAnchorElement.hashA string representing the fragment identifier, including the leading hash mark (#), if any, in the referenced URL.
HTMLAnchorElement.hostA string representing the hostname and port (if it's not the default port) in the referenced URL.
HTMLAnchorElement.hostnameA string representing the hostname in the referenced URL.
HTMLAnchorElement.hrefA string that is the result of parsing the href HTML attribute relative to the document, containing a valid URL of a linked resource.
HTMLAnchorElement.hreflangA string that reflects the hreflang HTML attribute, indicating the language of the linked resource.
HTMLAnchorElement.origin Read only
Returns a string containing the origin of the URL, that is its scheme, its domain and its port.
HTMLAnchorElement.passwordA string containing the password specified before the domain name.
HTMLAnchorElement.pathnameA string containing an initial / followed by the path of the URL, not including the query string or fragment.
HTMLAnchorElement.pingA space-separated list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs.
HTMLAnchorElement.portA string representing the port component, if any, of the referenced URL.
HTMLAnchorElement.protocolA string representing the protocol component, including trailing colon (:), of the referenced URL.
HTMLAnchorElement.referrerPolicyA string that reflects the referrerpolicy HTML attribute indicating which referrer to use.
HTMLAnchorElement.relA string that reflects the rel HTML attribute, specifying the relationship of the target object to the linked object.
HTMLAnchorElement.relList Read only
Returns a DOMTokenList that reflects the rel HTML attribute, as a list of tokens.
HTMLAnchorElement.searchA string representing the search element, including leading question mark (?), if any, of the referenced URL.
HTMLAnchorElement.targetA string that reflects the target HTML attribute, indicating where to display the linked resource.
HTMLAnchorElement.textA string being a synonym for the Node.textContent property.
HTMLAnchorElement.typeA string that reflects the type HTML attribute, indicating the MIME type of the linked resource.
HTMLAnchorElement.usernameA string containing the username specified before the domain name.
HTMLAnchorElement.charset Deprecated A string representing the character encoding of the linked resource.
HTMLAnchorElement.coords Deprecated A string representing a comma-separated list of coordinates.
HTMLAnchorElement.name Deprecated A string representing the anchor name.
HTMLAnchorElement.rev Deprecated A string representing that the rev HTML attribute, specifying the relationship of the link object to the target object.
HTMLAnchorElement.shape Deprecated A string representing the shape of the active area.
Inherits methods from its parent, HTMLElement.
HTMLAnchorElement.toString()Returns a string containing the whole URL. It is a synonym for HTMLAnchorElement.href, though it can't be used to modify the value.
| Specification |
|---|
| HTML> # htmlanchorelement> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HTMLAnchorElement |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 3 | 1 |
attributionSourceId |
No | No | No | No | 15.414.1–15.4 | No | No | No | 15.414.5–15.4 | No | No | 15.414.5–15.4 |
attributionSrc |
125 | 125 | No | 111 | No | 125 | No | 83 | No | 27.0 | 125 | No |
charset |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
coords |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
download |
15 | 13 | 20 | 15 | 10.1 | 18 | 20 | 14 | 10.3 | 1.0 | 4.4 | 10.3 |
hash |
1 | 12 | 1From Firefox 29 to Firefox 40, the returned value was incorrectly percent-decoded. |
15 | 1 | 18 | 4From Firefox for Android 29 to Firefox for Android 40, the returned value was incorrectly percent-decoded. |
14 | 1 | 1.0 | 4.4 | 1 |
host |
1 | 12 | 1 | 15 | 1 | 18 | 4 | 14 | 1 | 1.0 | 4.4 | 1 |
hostname |
1 | 12 | 1 | 15 | 1 | 18 | 4 | 14 | 1 | 1.0 | 4.4 | 1 |
href |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
hrefTranslate |
81 | No | No | 68 | No | 81 | No | 58 | No | 13.0 | 81 | No |
hreflang |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
name |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
origin |
8 | 17 | 26Before Firefox 49, results for URL using theblob scheme incorrectly returned null. |
15 | 5.1 | 18 | 26Before Firefox for Android 49, results for URL using theblob scheme incorrectly returned null. |
14 | 5 | 1.0 | 3 | 5 |
password |
32 | 79 | 26 | 19 | 10 | 32 | 26 | 19 | 10 | 2.0 | 4.4.3 | 10 |
pathname |
1 | 12 | 1Before Firefox 53, thepathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of https://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return '', rather than '/x' and '?a=true&b=false' respectively. This has now been fixed. |
15 | 1 | 18 | 4Before Firefox for Android 53, thepathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of https://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return '', rather than '/x' and '?a=true&b=false' respectively. This has now been fixed. |
14 | 1 | 1.0 | 4.4 | 1 |
ping |
12 | 17 | 1This property is exposed but has no effect if thebrowser.send_pings preference is not set to true. See bug 951104. |
15 | 5.1 | 18 | 4This property is exposed but has no effect if thebrowser.send_pings preference is not set to true. See bug 951104. |
14 | 5 | 1.0 | 4.4 | 5 |
port |
1 | 12 | 1 | 15 | 1 | 18 | 4 | 14 | 1 | 1.0 | 4.4 | 1 |
protocol |
1 | 12 | 1 | 15 | 1 | 18 | 4 | 14 | 1 | 1.0 | 4.4 | 1 |
referrerPolicy |
5251–52 | 79 | 50 | 3938–39 | 14 | 5251–52 | 50 | 41 | 14 | 6.05.0–6.0 | 5251–52 | 14 |
rel |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
relList |
65 | 18 | 30 | 52 | 9 | 65 | 30 | 47 | 9 | 9.0 | 65 | 9 |
rev |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
search |
1 | 12 | 1Before Firefox 53, thepathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of https://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return '', rather than '/x' and '?a=true&b=false' respectively. This has now been fixed. |
15 | 1 | 18 | 4Before Firefox for Android 53, thepathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of https://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return '', rather than '/x' and '?a=true&b=false' respectively. This has now been fixed. |
14 | 1 | 1.0 | 4.4 | 1 |
shape |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
target |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
text |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
toString |
52 | 12 | 22 | 39 | 3 | 52 | 22 | 41 | 1 | 6.0 | 52 | 1 |
type |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
username |
32 | 79 | 26 | 19 | 10 | 32 | 26 | 19 | 10 | 2.0 | 4.4.3 | 10 |
<a>
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement