Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<a>

A link to another page, a file or a place on the page.

Syntax

<a href="url">Link text</a>

Attributes

ParameterTypeDescription
hrefURLThe address the link leads to.
target_blankOptional. `_blank` opens the link in a new tab.
downloadfile nameOptional. 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

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.

Thanks for reading!

Donate to the site — we work hard for you.