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.
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.
- 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.)
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
- _self: the current browsing context. (Default)
- _blank: usually a new tab, but users can configure browsers to open a new window instead.
- _parent: the parent browsing context of the current one. If no parent, behaves as _self.
- _top: the topmost browsing context (the “highest” context that’s an ancestor of the current one). If no ancestors, behaves as _self.
Note: When using target, add rel=”noreferrer noopener” to avoid exploitation of the window.opener API;
type Hints at the linked URL’s format with a MIME type. No built-in functionality.
Note: This attribute is obsolete and should not be used by authors. Use the HTTP Content-Type: header on the linked URL.
coordsObsolete since HTML5 Used with the shape attribute. A comma-separated list of coordinates. nameObsolete since HTML5 Was required to define a possible target location in a page. In HTML 4.01, id and name could both be used on , as long as they had identical values.
Note: Use the global attribute id instead.
revObsolete since HTML5 Specified a reverse link; the opposite of the rel attribute. Deprecated for being very confusing. shapeObsolete since HTML5 The shape of the hyperlink’s region in an image map. Note: