Save your contact page from spam

there are a couple of different methods for blocking email harvesting bots from your contact page. Some involve javascript and obfuscating the email address. some involve putting the address in an image. my new favorite trick involves both.
first, go get your email address turned into escaped HTML characters. Take the code they give you, and wrap it in a span with a specific class, and add the same class to the link:

<span class="jsmail"><!--
document.write("<a href='mailto:put your scrambled address here' class='jsmail'> wp-admin [at] archgfx [dot] net</a>"))
// --> 



I also changed the ‘contact us!’ text to a human readable, but not copyable version of the email address. Now, get your email turned into an image, and we’re going to use the image in CSS, so that even if a real person is browsing the site with javascript disabled, they’ll still see the email address:

.jsmail {

display: block;

width: 129px;

height: 11px;

background: url('') no-repeat 0 0;

text-indent: -9000px;


i like it. it’s not completely accessible, but it’s pretty good. it’s reliable, and it won’t be confusing to people with older browsers or strict security settings. Here’s an example.


One thought on “Save your contact page from spam

  1. adam Post author

    sorry, wordpress doesn’t seem to believe me that i want the email address to remain encoded.

Comments are closed.