HTML href Attribute


The href attribute in HTML (Hypertext Markup Language) is used to specify the URL (Uniform Resource Locator) of a page that a link leads to. It stands for "Hypertext Reference" and is an essential part of the <a> anchor tag, enabling the creation of hyperlinks in web documents. Through hyperlinks, users can navigate from one web page to another, or to different sections within the same page, or even to download files.

The value of the href attribute can be an absolute URL, which provides the full path to the resource, or a relative URL, which indicates the resource's path in relation to the current document's path. Additionally, it can be used to create links to email addresses (using mailto:), telephone numbers (using tel:), and more.

Syntax example:

<a href="">Visit Example</a>

In this example, clicking on "Visit Example" would direct the user to the homepage of The href attribute can also be used within other elements like <link> and <base> for linking CSS files or setting a base URL for all relative URLs in a document, respectively, though its most common use is within the <a> tag for creating hyperlinks.


<tagname href="URL">


  • URLURL or path of the page or resource.

Applies To

The href attribute can be used on the following html elements.


<a href="">Click here to visit our website!</a>

Browser Support

The following table will show you the current browser support for the HTML href Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 29th March 2024