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="" 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.

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image