How Not to Use Links

mirror of /links.asp

Accessible scripting index | tom.me.uk home

They put the hypertext in the markup language. They are what glue the web together. They are the A Element, or hypertext links. But - yet again - they are used wrongly. A lot.

The Problem

Put very simply, links should be used for navigating between pages and objects - not for just triggering script events. For example...

<a href="#" onclick="doSomething(); return false;">Link text</a>

...and...

<a href="javascript:doSomething();">Link text</a>

...and...

<a href="javascript:void(0);" onclick="doSomething();">Link text</a>

...are all very poor usage of the A element.

The Solution

You have two options, depending on the circumstances of the link. If it is part of an interface the user would only get