How to create a link to send email in HTML?


We use HTML <a> tag defines a hyperlink used to link web pages.

The href attribute of the <a> tag, which indicates the link's destination. Which provides us option to specify an email address. To create a link to send mail we use mailto:to specify email address inside href attribute in HTML.

Syntax

Following is the syntax to link a mail address to the web page.

<a href="mailto:xx@gmail.com">xx@gmail.com</a>

Same as the way we link a mobile number. We use mailto instead of tel inside a href attribute.

Example

Following is the example program to link a mail address to the web page.

<!DOCTYPE html> <html> <head><title>None</title></head> <body> <p><a href="mailto:lokesh@gmail.com">lokesh@gmail.com</a></p> </body> </html>

When we click on the email address it will navigate us to the default mail app in our system.

Example

Following is another example program to link a mail address to the web page.

<!DOCTYPE html> <html> <head> <title>HTML email link</title> </head> <body> <h2>Contact</h2> <p>For any queries: <a href="mailto:demo@example.com">Contact us</a></p> </body> </html>

Example

Following is one more example program to link a mail address to the web page.

<!DOCTYPE html> <html> <body> <h2>Creating a link to send email in HTML</h2> <ol> <li><a href="mailto:someone1@example.com">Mail 1</a></li> <li><a href="mailto:someone2@example.com">Mail 2</a></li> <li><a href="mailto:someone3@example.com">Mail 3</a></li> </ol> </body> </html>

Updated on: 18-Nov-2022

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements