Links vs. JavaScript Event Handlers
Anchor tags are frequently used to do something other than what they were meant for, such as executing some JavaScript code. I’m talking about cases such as these:
<a href="javascript:doSomething()">Click Here</a> // or... <a href="javascript:void(0)" onclick="doSomething()">Click Here</a>
Both of these are bad practice and should be avoided. The purpose of the anchor tag is to provide a link to a separate page so that the its interpreter (human or program, such as a search crawler) can use the value of its HREF attribute to reach another page (URL). If what you are putting into the HREF attribute is not a valid URL, you’re very likely using the wrong tag.




Subchild is a blog about web development. It's author is Aleksandar Kolundzija, himself a web developer
for 10++ years, presently a Hacker-in-Residence at betaworks. Prior to betaworks, Alex worked at Google, Meebo,
MLB Advanced Media (MLB.com), Razorfish, and elsewhere.