posted on:February 18, 2008
Fighting Form Spam With Css
Fighting form spam is something almost every website owner has to face. If you allow comments on your site you will most likely be a subject of form spam attacks. The most effective and most popular way of fighting form spam is using generated images (captchas) that contain text that user should then retype into an input field. Since there are OCR algorithms that can read images, most of the time captchas contain messy and distorted text.
Fresh Solution
Messy and distorted text can be annoying to users, that it can prevent them from posting a comment. One more thing that can make to think twice when it comes to using some of the existing captcha solutions, is the fact that you can’t control their appearance. Generated images can be, well – ugly! To a delicate designer soul that can be even greater issue than spending time every day moderating comments.
So how about we call CSS to the rescue.
The trick I am using on my comment forms doesn’t appear to be that much different from regular captchas. But there is a great difference.
As we said there are some OCR technologies that can recognize symbols on the image. But in order for that to work you must have an image to start with.
Well, I don’t use <img> tag so OCR doesn’t apply to this trick. Instead, I use background image displayed with css. You’ll agree when I say that there’s absolutely no way that a robot can scan your html, locate your css file, compare css selectors, find a css definition, locate the image and read the image using OCR algorithm.
Here’s a sample code from my form. You can of course use the same principle on your own form’s markup.
The html code
<p> <label class="captcha" for="captcha">Answer?</label> <input type="text" name="captcha" id="captcha" /> </p>
The css code
label.captcha{ display:block; background:url(/images/captcha.gif) no-repeat 0 0; height:28px; line-height:28px; padding-left:90px; margin-bottom:.5em; }
Good sides
Good sides would be having easiest possible captcha and ability to design it anyway you like. You can put your own text, simple mathematical function, whatever…
Downsides
Downside to this trick is that people browsing your site with css disabled readers can’t tell what you’re asking them to do. Unfortunately, using this trick you prevent a part of your audience from commenting.
Enjoyed the article?
Then don't miss our next one! Subscribe to our RSS feed or share it with your friends.
Share on FacebookTweet thisDeliciousStumbleUpon RedditSubscribe
Comments (39 Comments)
Sorry, the comment form is closed at this time.
Catar4x
February 18, 2008
Brian Rock
February 18, 2008
warnis
February 19, 2008
James
February 19, 2008
Felipe
February 19, 2008
Jermayn
February 19, 2008
cssglobe
February 19, 2008
Barney
February 19, 2008
Julien
February 19, 2008
Dennison Uy - Graphic Designer
February 19, 2008
Julien
February 19, 2008
kik
February 19, 2008
Sarah
February 19, 2008
Iain Fraser
February 20, 2008
Josh A.
February 20, 2008
Fodcj
February 20, 2008
James Coletti
February 21, 2008
derek allard
February 21, 2008
Sirius
February 22, 2008
John
February 23, 2008
Richard
March 4, 2008
Ralph
March 7, 2008
Test Commenter
April 7, 2008
Dave
April 13, 2008
Eric
April 28, 2008
Arabia
June 11, 2008
Nikita Baffix
June 14, 2008
Miadeo
June 20, 2008
sander houttekier
July 23, 2008
smt
December 1, 2008
Busby SEO
December 2, 2008
Busby SEO Test
January 7, 2009
busby seo test info
January 13, 2009
Inventory Management Software
January 21, 2009
Barbara
January 30, 2009
craig
February 7, 2009
gosip artis
April 11, 2009
redips
May 1, 2009
Kris Utter
June 16, 2009