HTML

HTMLAnchorElement

HTMLAnchorElement <a>

The HTMLAnchorElement interface represents hyperlink elements and offers unique attributes and methods for tweaking their presentation and layout. This interface is mapped to <a> element; not to be confused with <link>, which is represented by HTMLLinkElement). The anchor element indicates that the information inside is a hyperlink,which is used to link from one page to another.

Attribute Value Description Example
download filename Specifies that the target will be downloaded when a user clicks on the hyperlink. <a href="/images/myw3schoolsimage.jpg" download="w3logo">
href URL Specifies the URL of the page the link goes to <a href="https://www.google.com">Visit Google</a>
hreflang language_code Specifies the language of the linked document <a href="https://www.google.com" hreflang="en">Google</a>
media media_query Specifies what media/device the linked document is optimized for <a href="att_a_media.asp?output=print" media="print and (resolution:300dpi)"> Open media attribute page for print.</a>
ping list_of_URLs Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking. <a href="https://www.google.com/html" ping="https://www.google.com/trackpings"></a>
referrerpolicy no-referrer No referrer information is sent <a href="https://www.google.com" referrerpolicy="origin"></a>
no-referrer-when-downgrade Default. Sends the origin, path, and query string if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP is not ok)
origin Sends the origin (scheme, host, and port) of the document
origin-when-cross-origin Sends the origin of the document for cross-origin request. Sends the origin, path, and query string for same-origin request
same-origin Sends a referrer for same-origin request. Sends no referrer for cross-origin request
strict-origin-when-cross-origin Sends the origin if the protocol security level stays the same or is higher (HTTP to HTTP, HTTPS to HTTPS, and HTTP to HTTPS is ok). Sends nothing to less secure level (HTTPS to HTTP)
unsafe-url Sends the origin, path, and query string (regardless of security). Use this value carefully!
rel alternate Provides a link to an alternate representation of the document (i.e. print page, translated or mirror) <a rel="nofollow" href="http://www.functravel.com/">Cheap Flights</a>
author Provides a link to the author of the document
bookmark Permanent URL used for bookmarking
external Indicates that the referenced document is not part of the same site as the current document
help Provides a link to a help document
license Provides a link to licensing information for the document
next Provides a link to the next document in the series
nofollow Links to an unendorsed document, like a paid link. ("nofollow" is used by Google, to specify that the Google search spider should not follow that link)
next Provides a link to the next document in the series
noopener Requires that any browsing context created by following the hyperlink must not have an opener browsing context
noreferrer Makes the referrer unknown. No referer header will be included when the user clicks the hyperlink
prev The previous document in a selection
search Links to a search tool for the document
tag A tag (keyword) for the current document
target _blank Opens the linked document in a new window or tab <a href="https://www.google.com" target="_blank">Google</a>
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in the named iframe
type media_type Specifies the media type of the linked document. <a href="https://www.google.com" type="text/html">Google</a>

Browser Compatibility

Element Chrome Edge Firefox Safari Opera
<a> Yes Yes Yes Yes Yes