Skip to content
Find email addresses in web pages and turn them into clickable <a href=mailto...>
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A small jquery/javascript file to find email addresses in web pages and turn them into clickable <a href=mailto...>.

It is common to avoid using <a href=mailto...> in web pages to prevent spammers from harvesting your email address. If you put your email address in plain text on the page and add markup to identify it, the javascript file will add additional <a> markup to turn it into a normal "clickable" anchor element.

To use, add the javascript file to your page:

<script src="create-mailto.js">

Then, in the web page, add markup to your email addresses:

<span class="email"></span>

That's it!

If you use microformats or microdata, you can use the class names mandated by those standards, without adding any additional markup:

using microformats hCard 1.0
this <span class="email"></span>
becomes <span class="email"><a href=""></a></span>
using microformats2 hcard
this <span class="p-email"></span>
becomes <span class="p-email"><a href=""></a></span>
using person microdata
this <span itemprop="email"></itemprop>
becomes <span itemprop="email"><a href=""></a></span>

You can also use this script in situations where the email address does not appear in the web page, by using data-*. Just add a data-email attribute to your element:

using text that is not an email address
this <span data-email="">email me</span>
becomes <span data-email=""><a href="">email me</a></span>
using an image element
this <img src="foo.jpg" alt="email me" data-email="">
becomes <a href=""><img src="foo.jpg" alt="email me" data-email=""></a>
You can’t perform that action at this time.