The <a> tag
The <a> tag creates a hyperlink to another document, a page section, a file, an email address, or any other URL.
Syntax
<a href="https://example.com">link text</a> Attributes
| href | The URL the link points to. Can be absolute, relative, an anchor (#id), or mailto:/tel:. |
| target | "_blank" opens the link in a new tab. Pair target="_blank" with rel="noopener". |
| rel | Relationship to the target document: noopener, noreferrer, nofollow, etc. |
| download | Hints the browser to download the file instead of navigating; you can also specify a filename as its value. |
Example
<a href="/pricing">Pricing</a>
<a href="https://example.com" target="_blank" rel="noopener">External link</a>
<a href="#section-2">Jump to section 2</a>
Notes
- target="_blank" without rel="noopener" gives the new page access to window.opener — a security risk, so always add rel="noopener".
- An empty href or href="#" makes the element clickable without a real navigation — for actions that don't navigate, use a <button> instead.
Accessibility
- Link text should describe its purpose ("Read more about pricing", not just "Here").
- Icon-only links need an aria-label describing the action.
Related tools
The href attribute
The href attribute of a and link elements: the URL a link or resource points to.
The target attribute
The target attribute of a and form: which browsing context (tab/frame) to open the result in.
The <img> tag
The src, alt, loading, and srcset attributes of the <img> tag, with examples.
URL Encode/Decode
Percent-encode and decode URL components in your browser.