Back to HTML Notes
Topic #116

Email Links

Learn how to create functional email links that open the user's default mail client, optionally pre-filling subject and body text, while understanding basic spam mitigation strategies.

What it is

An mailto: link is a URI scheme used in HTML anchors (<a>) to initiate an email composition window. When clicked, it triggers the operating system or browser to launch the configured default email client (such as Outlook, Apple Mail, or Thunderbird) with a new message draft. The recipient address is mandatory, but you can also specify parameters like subject, body, cc, and bcc.

The mental model is simple: it is not sending an email directly from the website; it is handing off control to the local email application. Related terms include "URI scheme," "query string," and "URL encoding."

Why it matters

  • User Convenience: It saves users from manually copying addresses and typing standard subjects.
  • Context Preservation: Pre-filled bodies allow you to include page URLs or reference numbers automatically.
  • No Backend Required: Unlike contact forms, it requires no server-side processing or database storage.
  • Accessibility: Properly labeled links are easily navigable by screen readers.

Syntax or steps

The basic structure follows standard URL syntax:

  1. Start with mailto: followed immediately by the email address.
  2. Add a question mark ? to begin query parameters.
  3. Append key-value pairs separated by ampersands &.
  4. Use %20 for spaces and %0A for line breaks in text values.

Example

<p>Contact us via <a href="mailto:support@example.com?subject=Website%20Feedback&body=Hello,%0AI%20would%20like%20to%20report%20an%20issue.%0A%0APage:%20https://example.com">email</a>.</p>

Part-by-part explanation:

  • mailto:support@example.com: Defines the recipient.
  • ?subject=...: Sets the email subject line. Note that spaces are encoded as %20.
  • &body=...: Adds a second parameter. The & separates parameters.
  • %0A: Represents a newline character within the body text.
  • <a>...</a>: The anchor tag wrapping the clickable text.

Common mistakes

  • Unencoded Spaces: Writing subject=My Subject instead of subject=My%20Subject. Browsers may handle this inconsistently; always encode special characters.
  • Missing Question Mark: Forgetting the ? before parameters results in the entire string being treated as the email address, causing failure.
  • Over-reliance on Body Text: Some email clients ignore the body parameter entirely. Never assume the user will see your pre-filled text.
  • Plain Text Exposure: Hardcoding mailto: links exposes your email address to web scrapers, increasing spam risk.

When to use it

Compare mailto: links with HTML Contact Forms:

FeatureMailto LinkContact Form
Spam ProtectionPoor (exposed address)Good (can add CAPTCHA/validation)
Setup ComplexityVery LowMedium (requires backend)
User ExperienceOpens external appStays on site
Data ControlNoneFull logging/storage

Use mailto: for simple personal sites or when you want to avoid server maintenance. Use forms for business sites requiring lead tracking or spam prevention.

Practice

Guided Exercise: Create a link that sends an email to info@shop.com with the subject "Order Inquiry" and a body containing "Hi, I have a question about order #12345." Ensure all spaces are correctly encoded.

Challenge: Modify your solution to include a CC address of manager@shop.com. Hint: Use the cc parameter.

Quick check

Question: What character sequence represents a space in a URL-encoded string?

Answer: %20

Summary

Email links provide a lightweight way to initiate communication without backend infrastructure, relying on the user's local email client. While convenient, they require careful URL encoding and offer little protection against spam harvesting compared to interactive forms.

Want to go beyond the notes?

Join Coding Now Tech Institute's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Email Links – FAQs

Quick answers about learning Email Links in HTML.

This free note from Coding Now Tech Institute explains Email Links in HTML — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every HTML topic on Coding Now Tech Institute, including Email Links, is 100% free with no signup required.
With focused practice, most students grasp Email Links in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now