Href for JavaScript links: "#" or "javascript:void(0)"?

When building a link that has the sole purpose to run JavaScript code, is it better to





1 Like


	If you can have an actual URL that makes sense use that as the HREF. The onclick won't fire if someone middle-clicks on your link to open a new tab or if they have JavaScript disabled.

	If that is not possible, then you should at least inject the anchor tag into the document with JavaScript and the appropriate click event handlers.

	I realize this isn't always possible, but in my opinion it should be striven for in developing any public website.

	Check out: [](