Sometimes you want to give something the appearance of a link, but not actually link to anything. This can be particularly useful when activating a JavaScript function, for example. However, we have a small problem:

Empty Links

If you put any text at all between the quotes of the <a href=""> link, the browser will attempt to find that resource. So what do you do?

The answer is to link to a hash / pound symbol (#). This will give the appearance of a link, but the link won’t actually do anything. For example:

<a href="#">This looks like a link</a>,
but it really only appears that way:
it won’t go anywhere when clicked

In theory you can surround almost any element with a link. Text and images are the most commonly linked elements, but under the DOM, a href can be applied to any element - tables, horizontal rules, anything.

eMail Links

It’s also possible to link to an eMail address:

<a href="mailto:youraddress@yourmailserver.com">

This can be taken further, to include a subject line:

<a href="mailto:youraddress@yourmailserver.com?subject=Subject Line Here">

While useful in principle - clicking on a link will start the user's default eMail application, creating an eMail addressed with the information supplied in the link - the approach has several problems:

  1. You're assuming that the user has correctly set up an eMail application (Chrome takes advantage of signed-in users by taking them to their gMail account).
  2. You're also assuming the user won't respond with panic to this unexpected behaviour.
  3. Historically, this technique has been used by spammers to harvest eMail addresses from web pages.

It's a perfectly good, even advisable practice for a business site, but in general a better technique is to make a PHP form that will send the contents of a textbox that the user completes to an eMail address.