How to create a mailto link with an ampersand
A little challenge I came across today was including an email address in an email that contained an ampersand.
The email address looked a little like this:
The problem was that whenever I used mailto:email@example.com, if I then click on the link from my inbox, a new message window would appear with just an ‘a’ in the To field.
The solution to this issue was fairly simple; I just needed to replace the ampersand with its hex code, so I changed it to firstname.lastname@example.org.
So the full markup looked a little something like this:
<a href="mailto:email@example.com">Get In Touch</a>