Links & Navigation
HTML <a> element
Creates a hyperlink when href is present. Use descriptive link text; without href it is a placeholder rather than an ordinary interactive hyperlink. Use descriptive link text that states the destination or action. Use a button for actions that do not navigate. A fragment URL can target an ID on the same page. For new browsing contexts, consider opener isolation and tell users when unexpected navigation opens a new tab. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<a href="URL">Link text</a>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| href | URL | Specifies a link destination, resource URL or document base URL depending on the element. An anchor without href is not a normal navigable hyperlink. Relative URLs resolve against the document base URL. |
| target | browsing context name or reserved keyword | Selects where a link or form opens. _self uses the current context; _blank requests a new context. Use appropriate opener isolation when opening external pages. |
| download | optional suggested filename | Requests download rather than navigation for an eligible link. Browsers may restrict cross-origin downloads and can adjust the suggested filename. |
| ping | space-separated HTTP(S) URLs | Lists endpoints that can receive hyperlink-auditing POST requests when a link is followed. Privacy settings or browser behavior may restrict it. Do not rely on it for essential logic. |
| rel | space-separated relationship keywords | Defines relationships between a document and a linked resource or navigation target. Valid tokens depend on the element; stylesheet, noopener and canonical have different purposes. |
| hreflang | BCP 47 language tag | Advises the language of a linked resource; it does not translate content or force a browser to use that language. |
| type | element-dependent keyword or MIME type | Selects an element-specific kind: input control state, button behavior, ordered-list numbering, script interpretation or resource media type. Consult the element's own allowed values. |
| referrerpolicy | referrer policy keyword | Controls the referrer information sent with an eligible fetch or navigation. no-referrer omits it; strict-origin-when-cross-origin is a common default policy. It does not prevent all tracking. |
Return Value
HTMLAnchorElement
Content model: Transparent content; no nested anchor, interactive descendants or descendants with tabindex.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <a href="#contact">Contact details</a> <h2 id="contact">Contact</h2> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines
Widely Available (2015)
Blink (modern)
Chrome
1
Yes
EdgeHTML / Blink
Edge
12
Yes
Gecko
Firefox
1
Yes
WebKit
Safari
1
Yes
Support for this specific feature in the checked browser data. Subfeatures may differ.
HTML Living Standard