How do you create an email link?

In Brief...

Use "mailto" to create a link that attempts to open a user's email client and set the "to" address.

Instructions

A email link is written using the <a> just like a regular link. Just set the href attribute to "mailto:" followed by the user's email address. For example:

<a href="mailto:gwashington@example.com">Email Link Text Here</a>

Some things you will want to consider:

  1. Email links only work if the user has an email client set up. As such, you should consider setting the text of the link to the email address itself so that users who don't have their email clients set up can find the email address.
  2. Email addresses in mailto links are easily discoverable by bots, so don't be surprised if your spam level increases after you use your email address in a mailto link.
  3. You can set a default subject a default subject and body using the subject and body parameters, like this:
    <a href="mailto:gwashington@example.com?subject=Revolutionary War&body=Nice job with that!">gwashington@example.com</a>

Give it a try

gwashington@example.com

Related Training

Author: Nat Dunn

Nat Dunn founded Webucator in 2003 to combine his passion for web development with his business expertise and to help companies benefit from both.

Discuss