Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

href

The address an `<a>` link leads to or a `<link>` points at.

Syntax

<a href="https://example.com">…</a>

Parameters

ParameterTypeDescription
hrefURLA full address, a path on the site, `#id`, `mailto:` or `tel:`.

Examples

Different kinds of addresses:

<ul>
  <li><a href="https://example.com/menu">Absolute: another site</a></li>
  <li><a href="/contacts">Root-relative: from the site root</a></li>
  <li><a href="about.html">Relative: next to this page</a></li>
  <li><a href="#top">Anchor: a place on this page</a></li>
  <li><a href="mailto:hello@example.com">Email</a> and <a href="tel:+15550100">phone</a></li>
</ul>

Notes

A path starting with a slash (/contacts) is resolved from the site root, one without it (about.html) — from the current page's folder, and ../ goes one level up. An <a> without href is not a link: it cannot be reached with Tab.

See also

  • <a> — A link to another page, a file or a place on the page.
  • target — `target` chooses where a link opens; `rel` describes the relation to the linked page.
  • <link> — Links an external resource to the page: a stylesheet, the site icon, a font.
  • <base> — Sets the base address and the default target for all links on the page.

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.