Email links use the
mailto: attribute along with the
HRef attribute and the recipient's email address to accomplish this function.
Using the mailto: attribute to create an email link
<a href="mailto:firstname.lastname@example.org">click to email</a>
Clicking on a
mailto: link opens your email software and inserts the email address into the
If you'd like to make your link a little more user-friendly, you can also add a subject line by following the email address with a question mark (
?) and the subject attribute and value.
Adding a subject to the email
<a href="mailto:email@example.com?subject=feedback">click to email</a>
Mailto: link with subject line added.
You'll want to consider accessibility features for your links as well, especially the
title attribute and a description, and
tabindex if the sequential order of links on a given page is particularly important to your site visitors.
Adding accessibility features to
<a href="mailto:firstname.lastname@example.org?subject=feedback" title="click to email feedback" tabindex="3">click to email</a>
The title text now appears in a ToolTip as the mouse passes over the link. The
tabindex is set to
3, so the site visitor can press the Tab key three times to reach the link, a very helpful offering to those individuals with mobility impairments.