<a>
A link to another page, a file or a place on the page.
Syntax
<a href="url">Link text</a>Attributes
| Parameter | Type | Description |
|---|---|---|
| href | URL | The address the link leads to. |
| target | _blank | Optional. `_blank` opens the link in a new tab. |
| download | file name | Optional. Download the file instead of opening it. |
Examples
A regular link and a link in a new tab:
<p><a href="https://example.com">Go to the site</a></p>
<p><a href="https://example.com" target="_blank" rel="noopener">Open in a new tab</a></p>A link to an email, a phone and a place on the page:
<p><a href="mailto:hello@example.com">Write to us</a></p>
<p><a href="tel:+15550100">Call +1 555 0100</a></p>
<p><a href="#top">To the top</a></p>Notes
Link text should say where it leads: "Download the price list" is better than "here". If a click performs an action on the page rather than opening something, use a <button>, not a link.
See also
- href — The address an `<a>` link leads to or a `<link>` points at.
- target — `target` chooses where a link opens; `rel` describes the relation to the linked page.
- <img> — An image.
- <button> — A button: submits a form or triggers an action.
- download — Makes a link save the file instead of opening it, optionally under a different name.
Related recipes
- How to add a Skip to content link
- How to change a link's color and remove the underline
- How to hide a page from search engines
- How to make a file download link
- How to make a link look like a button
- How to make a phone or email link
- How to open a link in a new tab
- How to style link states: visited, hover, focus
- How to underline text and style the underline
In the tutorial
- Links — The a tag and the href attribute, absolute and relative addresses, jumps within a page, a new tab, email and phone links.