How to give e mail id link in html
To give an email ID link in HTML, you can use the <a>
tag with the mailto
protocol. Here's an example:
<a href="mailto:[email protected]">Contact us</a>
Replace [email protected]
with the actual email ID you want to link to.
When a user clicks on this link, their default email client will open with the email address pre-filled in the "To" field.
You can also add additional parameters to the mailto
link to specify the subject, body, and other details. Here are some examples:
- To specify the subject:
<a href="mailto:[email protected]?subject=Your%20Subject">Contact us</a>
- To specify the body:
<a href="mailto:[email protected]?body=Your%20Body">Contact us</a>
- To specify both subject and body:
<a href="mailto:[email protected]?subject=Your%20Subject&body=Your%20Body">Contact us</a>
Note that the
%20
is used to encode spaces in the subject and body.
You can also use the target
attribute to specify whether the email client should open in a new window or not. For example:
<a href="mailto:[email protected]" target="_blank">Contact us</a>
This will open the email client in a new window.
It's also a good practice to add a fallback text for users who don't have an email client installed or configured. You can do this by adding the title
attribute:
<a href="mailto:[email protected]" title="Email [email protected]">Contact us</a>
This will display the email address as a fallback text if the user doesn't have an email client installed or configured.