What is the HREF attribute and what does it mean?

We see href attributes all over in code, but what does it actually mean?

The href attribute is short for Hypertext Reference. It's used to represent a reference to another web address. Depending on the tag it's used with, it can serve different purposes.

You can reference another address you want to link to by using it inside an anchor tag.

<a href="https://testsuite.io">Link to a website</a>

You can also reference a specific part of the same page.

<a href="#table-of-content">Jump to table of contents</a>

You can reference the address of a stylesheet you want to import.

<link href="/styles.css" rel="stylesheet"/>

You would also use it to create a canonical link for SEO purposes. html <link href="https://testsuite.io/what-is-href" rel="canonical"/>

Regardless of the HTML tag that needs an href attribute, it means the same thing.

It designates the address of the resource being used.

And that's all there is to hrefs!

Level up faster
One on Ones: 101
Leveraging Other People's Experience
Business ideas
Check out my list.
Hey, I'm Nicholas Dill.

I help people become better software developers with daily tips, tricks, and advice.

Level up