HTMLpad

HTML Email Link: How to Write a Mailto Link

By · · 4 min read

A blank envelope resting on a light oak desk beside a sheet of paper, with a small orange wax seal on the envelope

To make an email link in HTML, use a normal link with mailto: and the address: <a href="mailto:hello@example.com">Email us</a>. Clicking it opens the reader's email app with a new message to that address. You can also fill in the subject, the body and extra recipients by adding them to the link.

Email links are simple, but they have a few traps: special characters that have to be encoded, readers with no email app set up, and spam bots that collect any address they find. This guide covers all three, with examples you can open and edit in HTMLpad.

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Email link</title></head>
<body>
  <p>Questions? <a href="mailto:hello@example.com">Email hello@example.com</a></p>
</body>
</html>

Try this example in HTMLpad

Showing the address in the link text, as above, helps readers who use webmail in the browser. If clicking does nothing for them, they can still copy the address.

Add a subject, a body and more recipients

Everything after a question mark becomes part of the new message. Separate each field with &.

Field What it does Example
subject Fills in the subject line ?subject=Price%20question
body Fills in the message &body=Hello%2C%20I%20would%20like...
cc Adds a copy recipient &cc=sales@example.com
bcc Adds a hidden recipient &bcc=archive@example.com

You can also send to several people at once by separating the addresses with commas: mailto:anna@example.com,ben@example.com. The format is defined in RFC 6068, the mailto URI scheme, which every email app follows.

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Email link with subject</title></head>
<body>
  <p><a href="mailto:hello@example.com?subject=Question%20about%20pricing&body=Hi%2C%0A%0AI%20would%20like%20to%20know%20more%20about%20your%20plans.%0A%0AThanks">Ask about pricing</a></p>
  <p><a href="mailto:support@example.com?cc=team@example.com&subject=Bug%20report">Report a bug</a></p>
</body>
</html>

Try this example in HTMLpad

Encode the text properly

Links cannot contain spaces or certain characters as they are. Inside a mailto link:

If you are writing the link by hand, write the message first, then replace those characters. If a script builds the link, use the browser's encodeURIComponent() function on the subject and the body, which handles every case for you. Some email apps tolerate unencoded spaces, but others cut the subject at the first one, so it is worth doing properly.

An email link is a normal link, so you can style it like any other. A common pattern on landing pages:

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Email button</title>
<style>
  .mail-btn { display: inline-block; background: #f25438; color: #151924; padding: .7rem 1.2rem;
    border-radius: 8px; font: 600 1rem system-ui, sans-serif; text-decoration: none; }
  .mail-btn:hover { background: #e0452b; }
</style></head>
<body>
  <a class="mail-btn" href="mailto:hello@example.com?subject=Hello">Write to us</a>
</body>
</html>

Try this example in HTMLpad

The HTML button link guide explains this styling in more detail and when a real button is the better element.

Mailto links depend on the reader's device. They work smoothly for people who use a mail app on their phone or computer. They work less well for people who only use webmail in the browser, where clicking may open an app they never set up.

Two other problems are worth weighing:

As a rule: a mailto link is fine for a personal page, a portfolio, a report or a one-page site. For a business that depends on inquiries, a form is usually the better choice, and it means your page needs something on a server to receive it. A static page cannot store form data on its own, which is one of the signs I describe in when a single HTML page isn't enough.

Open the page, click the link and look at the new message. Check the address, the subject and that line breaks landed where you wanted. Then copy the link address and paste it into a plain text note: any space or odd character that slipped through will be visible there.

For the general rules of links, including new tabs and links to sections, see HTML link code. For working with the files themselves, see how to edit an HTML file and the guide to opening HTML files.

Frequently asked questions

A link whose address starts with mailto: instead of https://. When clicked, it opens the reader's email app with a new message addressed to the email in the link.

Add ?subject= after the address, followed by the subject with spaces written as %20. For example, mailto:hello@example.com?subject=Order%20question.

The reader probably has no default email app set up, which is common for people who only use webmail. Showing the address in the link text lets them copy it instead.

Can I send an email directly from an HTML page?

Not with HTML alone. A mailto link only opens the reader's email app. Sending a message from the page itself needs a form connected to a service or a server that sends it.

More in Open and Edit HTML