如何在 HTML 中创建发送电子邮件的链接?

htmlweb developmentfront end technology更新于 2024/7/4 2:20:17

我们使用 HTML <a> 标签定义用于链接网页的超链接。

<a> 标签的 href 属性指示链接的目标。它为我们提供了指定电子邮件地址的选项。要创建发送邮件的链接,我们使用 mailto: 在 HTML 的 href 属性中指定电子邮件地址。

语法

以下是将邮件地址链接到网页的语法。

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

与我们链接手机号码的方式相同。我们在 href 属性中使用 mailto 代替 tel。

示例

以下是将邮件地址链接到网页的示例程序。

<!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.

示例

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>

示例

下面是另一个将邮件地址链接到网页的示例程序。

<!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>

相关文章


有用资源