I recently came across a website that contained an anchor element without a href attribute.

I immediately thought that was stupid, but, could there be an actual situation where having an anchor without a href makes sense?


In the old days, you used <a name="whatever"> if you wanted another link to jump to a particular point on the screen. Nowadays (for a long time actually) we use the "id" attribute.

  • I thought I remembered that, but didn't find it in a quick search, so didn't include it in my answer. May 12 '16 at 19:37

You could imagine that some Javascript code is dynamically changing the DOM to add that missing href= attribute dynamically at runtime.


W3Schools.com says:

In HTML 4.01, the tag could be either a hyperlink or an anchor. In HTML5, the tag is always a hyperlink, but if it has no href attribute, it is only a placeholder for a hyperlink.

I recommend against using an <a> tag without an href as a placeholder. Better to use <u> tags so that the broken links show up underlined black instead of the usual link color so that you can at least see which links are broken when you look at the page. Or fill in <a href="to-do"> so that a link checker can report the broken links.


No. You should never use anchor tag without href attribute.

I totally agree with Glen Peterson’s answer. Anchor element in HTML is always used with href attribute. And, without href, the element simply serves as a placeholder. But I also don’t suggest using without href just as a placeholder.

Moreover, using anchor element without href may slow down your browser. So, I advise that you use which denotes a page fragment.

And, in JQuery, you can use the following:

// Click code here...

Not the answer you're looking for? Browse other questions tagged or ask your own question.