Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


How to hide an email address from spambots?

Hi, I made a website for a friend in html and css and I wrote the email address normally clickable. Now I worry about spambots and would like to hide it from them. How can I do that? A friend recommended to hide it with Javascript, but I have little experience with Java. How would that code look like? And how to I add it to my html? Thank you!

Kevin Korte
Kevin Korte
28,148 Points

Just a quick note, Java and Javascript are completely different languages for different things. I noticed you used both names in your post, and just wanted to point that out. That way you don't get yourself confused learning how to do this. Erik's suggestion is good. Look for a tutorial how to obfuscate email address with javascript.

2 Answers

The simplest way to hide it from bots is to use an image instead of actual text, however this created a user experience issue in that the email address cannot be copied and pasted and is less accessible.

From my understanding the accepted solution is to use contact forms, but if you want to use JS, google something like "Obfuscate email address" to start researching.

Hope this helps!

Thank you guys, as you can tell, I didn't start the course on Javascript yet, so for me it was the same as Java until googling the difference now :) I found a solution with Google, like you suggested. In case someone else needs it, here it is: The "unspamable email link"