Skip to main content

HTML Text and Links

HTML Email Links

Written by Updated HTML Email Links exercises

An email link opens the reader's mail app with your address already filled in. It is an ordinary link whose href starts with mailto: instead of https:. You can even pre-fill the subject and the message.

Basic Email Link

Basic Example

html

<a href="mailto:contact@html5andcss3.org">Send Email</a>

When clicked, the default mail app opens a new message with the To field already filled. The link text is what readers see, so make it clear, like "Email our support team", rather than just "Click here".

Adding Subject and Body

Email with Subject Example

html

<a href="mailto:contact@html5andcss3.org?subject=Website%20Inquiry&body=Hello,%20I%20want%20to%20know%20more%20about%20your%20services.">Send Email</a>

After the address comes a ?, then each setting as name=value, joined with &. Spaces must be written as %20, and line breaks in the body as %0A. If the text contains & or ? itself, encode those too, or the link will cut off at that point.

CC and BCC Fields

CC, BCC Example

html

<a href="mailto:contact@html5andcss3.org?cc=support@example.com&bcc=admin@example.com&subject=Feedback">Send Feedback</a>

Both cc and bcc can take several addresses separated by commas.

Opening Gmail in the browser

mailto: uses whatever mail app is set as the default on the device. Many people, especially on laptops, have none set up, and then nothing happens when they click. If most of your readers use Gmail, you can link to its compose page instead:

Gmail Link Example

html

<a href="https://mail.google.com/mail/?view=cm&to=contact@html5andcss3.org" target="_blank">
  Send Email
</a>

The downside is that it only helps Gmail users. A safe pattern is to show the address as plain text next to the link, so anyone can copy it.

Good to know

  • Spam. An address written in a page is easy for bots to collect. A contact form avoids this, and is more reliable than mailto anyway.
  • Test on a phone. Phones handle mailto links well; desktop computers without a mail app set up do not.
  • Keep it short. Long pre-filled bodies can be cut off by some mail apps. Use the body for a starting line, not a whole letter.
  • Phone links work the same way. href="tel:+911234567890" opens the phone's dialer. More link types are covered in HTML Links.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

HTML Email Links exercises

An email link

Add a link with the text Email us that writes to hello@example.com.

Result

Check your answer to see it here.