How to create a link to send email with a subject in HTML?

To create a link that opens the user's email client with a pre-filled subject line, use the <a> tag with a mailto: URL in the href attribute.

Syntax

<a href="mailto:email@example.com?Subject=Your%20Subject">Link Text</a>

Key Points

  • Use mailto: followed by the recipient's email address
  • Add ?Subject= to include a subject line
  • Replace spaces in the subject with %20 (URL encoding)
  • The link will open the user's default email client

Basic Example

<!DOCTYPE html>
<html>
<head>
    <title>Email Link Example</title>
</head>
<body>
    <h2>Contact Us</h2>
    <p>Have questions? <a href="mailto:support@example.com?Subject=Customer%20Inquiry">Send us an email</a></p>
</body>
</html>

Advanced Example with Multiple Parameters

You can add additional parameters like CC, BCC, and body text:

<!DOCTYPE html>
<html>
<head>
    <title>Advanced Email Link</title>
</head>
<body>
    <h2>Contact Form</h2>
    
    <!-- Basic email with subject -->
    <p><a href="mailto:info@company.com?Subject=General%20Inquiry">General Questions</a></p>
    
    <!-- Email with subject and body -->
    <p><a href="mailto:support@company.com?Subject=Technical%20Support&body=Please%20describe%20your%20issue">Technical Support</a></p>
    
    <!-- Email with CC -->
    <p><a href="mailto:sales@company.com?Subject=Sales%20Inquiry&cc=manager@company.com">Sales Team</a></p>
</body>
</html>

URL Encoding Reference

Character URL Encoded Example
Space %20 "My Query" ? "My%20Query"
& %26 "Tom & Jerry" ? "Tom%20%26%20Jerry"
? %3F "Help?" ? "Help%3F"

Common Parameters

  • subject: Pre-fill the subject line
  • body: Pre-fill the email body
  • cc: Add CC recipients
  • bcc: Add BCC recipients

Conclusion

Use mailto: links to create email links with pre-filled subjects. Remember to URL-encode special characters, especially spaces (%20), for proper browser compatibility.

Updated on: 2026-03-15T22:16:53+05:30

21K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements