Skip to content

Consistency in href attribute #3

@thujone

Description

@thujone

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions