What Does the Href Attribute Do in Html?

Dan Gold

Written by Dan

The href attribute the attribute that you use in HTML to specify a hyperlink. It is used in the <a> (anchor) element, which represents a hyperlink to another page (internal to your website or external to the internet) or resource. The href attribute specifies the URL or location of the linked page or resource.

Here is an example of how the href attribute is used in an <a> element:

<a href="https://www.example.com">Visit our website</a>

Or if you’re using it to link to an internal page, you’d do something like this:

<a href="/cats.html">Read more about cats</a>

In these examples, the href attribute specifies the URL or page of the website that the visitor will be taken to when they click on the link. The text inside the <a> element, “Visit our website”, is the visible text of the link.

Unless you do any default styling with CSS, your links are typically blue with an underline.

Last updated

February 2nd, 2024