The href attribute

href sets the URL for a (hyperlinks) and link (linked resources: stylesheet, favicon, canonical, etc.) tags.

Applies to

a, link, area, base

Values

An absolute URL (https://...), a relative path, an anchor (#id), or a mailto:/tel: scheme.

Example

<a href="/pricing">Pricing</a>
<a href="mailto:info@example.com">Email us</a>

Edge cases

  • href="#" or an empty href makes a link clickable with no real navigation — often a sign a <button> would fit better.
  • Relative hrefs resolve against the current page (or <base> if set), which can produce unexpected paths with deeply nested routes.

Related tools