There are a few different ways to defeat (or "hijack") the href attribute in anchor tags:
<a href="javascript: void(0)"></a>
<a href="#"></a>
<a href="javascript:;"></a>
Why are things done this way? Because html4 and 5 make the href attribute mandatory. If you omit the href attribute, it will break many applications in Internet Explorer (IE8-11).
The first version has been around for many years but is not really in much use anymore.
The second one is probably the most standard, but when you click on it you'll notice it adds a '#' to the end your url, which is not a great thing.
The third version is one I usually use. This is a great discussion if you have a few minutes:
https://stackoverflow.com/questions/1291942/what-does-javascriptvoid0-mean
There are a few different ways to defeat (or "hijack") the
hrefattribute in anchor tags:Why are things done this way? Because html4 and 5 make the
hrefattribute mandatory. If you omit thehrefattribute, it will break many applications in Internet Explorer (IE8-11).The first version has been around for many years but is not really in much use anymore.
The second one is probably the most standard, but when you click on it you'll notice it adds a '#' to the end your url, which is not a great thing.
The third version is one I usually use. This is a great discussion if you have a few minutes:
https://stackoverflow.com/questions/1291942/what-does-javascriptvoid0-mean