MakeW3web

Email Links

Email links, also known as "mailto" links, are a type of hyperlink that, when clicked, opens the user's default email client with a new email message pre-filled with the specified recipient's email address. They can also include pre-filled subject lines and body text. Email links are created using the `mailto:` scheme in the `href` attribute of the `<a>` element.

Here's a simple email link example:

<a href="mailto:example@example.com">Email example@example.com</a>

When the user clicks this link, their email client will open a new message addressed to "example@example.com".

To include a pre-filled subject line, add the `subject` parameter:

<a href="mailto:example@example.com?subject=Website%20Inquiry">Email example@example.com with a subject</a>

This will create a new email with the subject line "Website Inquiry".

To add pre-filled body text, use the `body` parameter:

<a href="mailto:example@example.com?subject=Website%20Inquiry&amp;body=Hello,%0D%0AI%20have%20a%20question%20about%20your%20website.">Email example@example.com with a subject and body text</a>

This will create a new email with the subject "Website Inquiry" and the body text "Hello, I have a question about your website." Note the use of `%0D%0A` to create a newline in the body text.

You can also add multiple recipients by separating their email addresses with a comma:

<a href="mailto:example1@example.com,example2@example.com?subject=Website%20Inquiry">Email multiple recipients</a>

This will create a new email addressed to both "example1@example.com" and "example2@example.com".

Here's a combined example demonstrating the use of email links:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Email Links Example</title>
</head>
<body>
    <h1>Email Links</h1>
    
    <p><a href="mailto:example@example.com">Email example@example.com</a></p>
    
    <p><a href="mailto:example@example.com?subject=Website%20Inquiry">Email example@example.com with a subject</a></p>
    
    <p><a href="mailto:example@example.com?subject=Website%20Inquiry&amp;body=Hello,%0D%0AI%20have%20a%20question%20about%20your%20website.">Email example@example.com with a subject and body text</a></p>
    
    <p><a href="mailto:example1@example.com,example2@example.com?subject=Website%20Inquiry">Email multiple recipients</a></p>
</body>
</html>

Email links provide an easy way for users to send email messages directly from your website. However, keep in mind that not all users have a default email client configured, so it's a good idea to also provide an alternative contact method, such as a contact form or phone number.

Was this page helpful?