Href mailto
A simple but useful combination!
href
and mailto
are two HTML attributes that work together to create a clickable email link.
Here's the breakdown:
href
: This attribute specifies the URL of the link. In the case of an email link, thehref
attribute is set tomailto:
followed by the email address.mailto
: This is a special protocol that tells the browser to open the user's default email client or compose a new email message.
When you combine these two attributes, you get a clickable email link that, when clicked, opens the user's default email client or composes a new email message with the specified email address.
Here's an example:
<a href="mailto:[email protected]">Contact us</a>
In this example, the link text "Contact us" is wrapped in an <a>
tag with an href
attribute set to mailto:[email protected]
. When the user clicks on the link, their default email client will open with the email address [email protected]
already filled in.
You can also add additional parameters to the mailto
link to specify the subject, body, and other details of the email. For example:
<a href="mailto:[email protected]?subject=Hello&body=Hello%20again">Contact us</a>
In this example, the link will open with the subject "Hello" and the body "Hello again" already filled in. The %20
is used to encode the space character in the body text.