CSS Portal

HTML href Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
href
HTML AttributeThis attribute is supported by all modern browsers.
Updated 29th March 2024

Description

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="https://www.example.com">Visit Example</a>

In this example, clicking on "Visit Example" would direct the user to the homepage of www.example.com. 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.

Syntax

<tagname href="URL">

Values

  • URLURL or path of the page or resource.

Applies To

Example

<a href="https://www.cssportal.com">Click here to visit our website!</a>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML href attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee