HTML <a> href Attribute

An href on an <a> (anchor) tag defines the page or site to link to.

The value can be an internal or external URL.



An <a> element with an href attribute.
This link opens a page from an external site in a new browser tab.

Go to Wikipedia
Go to <a href="" 

Using href

The href attribute specifies the URL or path of the linked page.

It accepts any of these URLs:

  • absolute URL - link to a page on an external website or domain (e.g.
  • relative URL - link to an internal page on the same domain (with a shorter url)
  • anchor URL - link to an anchored section within the same page (with the # notation)

Note: If href is not set, the <a> element will not be treated as a link.


<a href="URL" />



Value Description
URL URL or path of the linked page.

Absolute URL

An <a> element with an absolute URL to Google.

<a href="" 

Relative URL

An <a> element with a relative URL to our SQL Tutorial on this website.

<a href="/sql">SQL Tutorial</a>

Anchor URL

An <a> element with an anchor URL which scrolls to the top of this page.

<a href="#top">Top</a>

Note: All browsers have a hidden <a id="top"> at the top which makes this work.
To jump elsewhere on the page you need to add <a id="mylocation"> to that location.

Browser support

Here is when href support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

 Back to <a>

Last updated on Sep 30, 2023