The HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.Content within each should indicate the link’s destination.

The source for this interactive example is stored in a GitHub repository. If you’d like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

Attributes

This element’s attributes include the global attributes.

downloadHTML5 Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:

  • Without a value, the browser will suggest a filename/extension, generated from various sources:
  • Defining a value suggests it as the filename. / and characters are converted to underscores (_). Filesystems may forbid other characters in filenames, so browsers will adjust the suggested name if necessary.

Notes:

  • download only works for same-origin URLs, or the blob: and data: schemes.
  • If Content-Disposition has a different filename than download, the header takes priority. (If Content-Disposition: inline, Firefox prefers the header while Chrome prefers download.)

href

The URL that the hyperlink points to. Links are not restricted to HTTP-based URLs — they can use any URL scheme supported by browsers:

  • Sections of a page with fragment URLs
  • Pieces of media files with media fragments
  • Telephone numbers with tel: URLs
  • Email addresses with mailto: URLs
  • While web browsers may not support other URL schemes, web sites can with registerProtocolHandler()

hreflang Hints at the human language of the linked URL. No built-in functionality. Allowed values are the same as the global lang attribute. ping A space-separated list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs. Typically for tracking. referrerpolicy How much of the referrer to send when following the link. See Referrer-Policy for possible values and their effects. rel The relationship of the linked URL as space-separated link types. target Where to display the linked URL, as the name for a browsing context (a tab, window, or