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.
It’s also possible to link to an eMail address:
This can be taken further, to include a subject line:
<a href="mailto:email@example.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:
- 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).
- You're also assuming the user won't respond with panic to this unexpected behaviour.
- 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.
Photograph by Aaron Shumaker, used under a Creative Commons Attribution Non-Commercial 2.0 Generic license. Sculptures by Hirotoshi Itoh.
Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.