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 <a href="https://en.wikipedia.org/wiki/Main_Page"
target="_blank">Wikipedia</a>
The href attribute specifies the URL or path of the linked page.
It accepts any of these URLs:
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. |
An <a> element with an absolute URL to Google.
<a href="https://www.google.com"
target="_blank">Google</a>
An <a> element with a relative URL to our SQL Tutorial on this website.
<a href="/sql">SQL Tutorial</a>
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.
Here is when href support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |
Back to <a>