Picture of Michael Lee
:wave: Hey hey, I'm Michael Lee and this is my site about being a developer, being a dad and making side projects.

Don't Forget the Address

Written on October 17, 2014

A common practice when architecting HTML is to wrap a group of elements with an anchor tag. This is so that clicking any of the elements within the anchor tag takes you to a linked page.

An example of this would be creating a button on a page.

<a href="https://michaelsoolee.com/subscribe" class="btn btn-primary">
	Click here to Subscribe
	<span class="icon icon-arrow"></span>

One of the benefits of using an anchor tag like this, is that you automatically get a pointer &mdash the little hand with the pointer finger raised — for the cursor.

Turns out, if you forget the href attribute from the anchor tag, you lose the cursor benefit. According to the official HTML spec doc for anchor tags:

The href attribute on a and area elements is not required; when those elements do not have href attributes they do not create hyperlinks.

Although the href attribute is not required, leaving it out does not create a hyperlink thus causing the element to not have the added benefit of the pointer cursor automatically.

So remember, when making a link, don’t forget the href attribute.

Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design and side projects. Sign up and I'll send you my articles straight to your email.