EOA Scratch Off Email

How to Create a “Scratch Off” Effect in Email HTML


The team at Email on Acid wanted to do something extra special to announce our Month of Giving holiday contest. So we came up with a fun design featuring “Email Gnomes” to give away gifts. At the centerpiece of this email, we designed a scratch-off ticket.

Now, “scratch off” functionality doesn’t really exist in email—at least not yet. That’s where coding magic comes into play.

Scratch-Off Email: Creating the Functionality

This interactive email renders in three stages. The interactivity is a “touch to unveil” function that reveals an animated GIF. This is what gives the illusion of a scratch off. Here are three scenarios how the “scratch off” will play out:

Scenario 1

If the email client supports the interactivity, then the functionality will display the animated GIF.

Scenario 2

If there isn’t support for interactivity, just the animated GIF will play.

Scenario 3

The fallback will display if there’s no support for the interactivity or GIF.

The Process

There are three different types of email clients, mobile, desktop, and web. Before building the email, we created the interactivity, and tested it—ensuring it worked properly. We built it with no content, and used images from Placeholder.com.  These placeholder images can be set to any size, and you can set custom text.

Here’s an example of what was used:

https://via.placeholder.com/500×500/?text=Touch To Unveil Image
https://via.placeholder.com/500×500/?text=Main Offer Animated GIF

Through this technique, and by running tests through Email on Acid, we were able to identify what scenario applied to the email (1,2, or 3).

Here’s an example of the interactivity working. The touch to unveil image is what you tap to play the animated GIF.

Example of interactivity working for scratch off coding.


Here’s an example of the fallback working. This will display in the email clients that don’t support the interactivity, or the animated GIF.

Example of fallback interactivity for scratch off coding.

Here’s an example of the animated GIF working.

Example of animated GIF for scratch off coding.


Add this code below between the <head></head> tags of the email. Don’t add it to any media queries you have in place for responsive design.

Using this WebKit media query, you can target email clients that support the :checked selector. The two CSS classes are created, .touch and .unveil. Then they combine as an ID with the tilde ~ and asterisk * before the class .unveil to address all interactive elements.

@media screen and (-webkit-min-device-pixel-ratio:0) {
.touch {
display: block !important;
mso-hide: all !important;
.unveil {
display: none
#touchunveil:checked ~ * .unveil {
display: block !important;
#touchunveil:checked ~ * .touch {
display: none !important;

The :checked selector is a pseudo-class that lets the user toggle content based on the state of a checkbox, all without using JavaScript. The selector represents any radio input using <input type=”radio”>. This applies the #touchunveil ID from the WebKit here. Below is the setup for the radio button that will unveil the animated GIF and let it play. The way the style tag is coded ensures it won’t show up in the scratch-off email.

<!--[if mso]><!-->
<input type="radio" name="touchunveil" id="touchunveil" style="mso-hide:all;display:none!important;height:0px;max-height:0px;overflow:hidden;font-size:0;margin-left:-10000px;">

You can read more about the CSS :checked selector here.


Wrapped in a Microsoft Outlook conditional statement, and referencing the WebKit classes in the CSS the table with the .touch class is displaying the first image. The table with the class of .unveil is not displaying, but will appear when the image with the.touch class is activated by being tapped. The image is wrapped in a label tag with name="touchunveil" id="touchunveil” and it activates the radio button input to switch out the image to the animated GIF of the scratch off.

<!--[if !mso]><!-->
<table width="600" role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" style="width:100%; max-width:600px;">
<td align="center" valign="top" bgcolor="#f4f4f4"><!-- Touch to Unveil -->
<table role="presentation" width="600" style="width:100%; max-width:600px;" cellpadding="0" cellspacing="0" border="0" align="center" class="100w">
<td align="center" valign="top"><!-- Main Offer Scratch Off  -->
<table class="unveil 100w" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%; max-width:600px;mso-hide:all;">
<td valign="middle" align="center" bgcolor="#FFFFFF"
style="color:#000001; font-family:serif; font-size:14px; mso-line-height-rule:exactly;line-height:22px; font-weight:400; padding:16px 0px 0px 0px;"
<td align="center"><a href="https://marketing.emailonacid.com/month-of-giving"><img src="https://marketing.emailonacid.com/hs-fs/hubfs/2019%20Email%20Images/Holiday%20Email/2019Holiday-Email-ScratchOff2.gif?upscale=true&name=2019Holiday-Email-ScratchOff2.gif" width="100%" height="auto" style="display:block;width:100%;max-width:600px;height:auto;" alt="Enter here for a chance to win one of our FREE EMAIL GIFTS! – LET’S GO" border="0" class="100w"></a></td>
<table class="touch" width="100%" border="0" cellspacing="0" cellpadding="0" style="mso-hide:all; display:none;">
<td valign="middle" align="center" bgcolor="#FFFFFF"
style="color:#000001; font-family:serif; font-size:14px; mso-line-height-rule:exactly;line-height:22px; font-weight:400; padding:16px 0px 0px 0px;"
class="em_padnon"><i>Click the gift below to find out&nbsp;you&nbsp;can&nbsp;win&nbsp;yours:</i></td>
<tr style="mso-hide:all">
<td align="center" style="mso-hide:all"><!-- Touch to Unveil Image  -->
<label for="touchunveil"> <img class="100w" border="0" src="https://marketing.emailonacid.com/hubfs/2019%20Email%20Images/Holiday%20Email/2019Holiday-Email-PreScratch.jpg" width="100%" style="width:100%;max-width:600px; display:block; mso-hide:all; height: auto;" alt=""> </label></td>
<!-- // End Touch to Unveil --></td>

** Note: Notice the empty alt=”” on the image for accessibility.

The Fallback

In the event you’re stuck with the third scenario (neither the functionality nor GIF rendering), you’re going to need a fallback of some sort—same as every other interactive email. Sometimes the fallback is just the interactivity not working, which actually makes developing a bit easier. In this example, the fallback is a static image that displays in clients that don’t support the interactivity or the GIF animation.

<!--[if gte mso 9]>
<table border="0" width="600" align="center" valign="top" cellpadding="0" cellspacing="0" bgcolor="#f4f4f4">
<td align="center" valign="top">
<table border="0" width="600" align="center" valign="top" cellpadding="0" cellspacing="0" bgcolor="#f4f4f4" style="padding:0px 0px 0px 0px; width:600px;">
<td align="center" valign="top"><img src="https://marketing.emailonacid.com/hubfs/2019%20Email%20Images/Holiday%20Email/2019Holiday-Email-FallbackImage.jpg" width="600" style="width:600px;" /></td>

Targeting Outlook.com and Office 365 via CSS

As we were close to completing the email, we noticed the GIF animation wasn’t playing in Outlook.com or Office 365 web clients. The interactivity wasn’t working, so the first image wasn’t disappearing. We needed to find a way to target these clients. By checking out How to Target Email Clients and some experimentation, we were able to target the web clients to render correctly and display the animated GIF upon the user opening the scratch-off email.


[class=“x_foo”] { }

Example used in CSS:

[class~="x_unveil"] {
display: block !important;
[class~="x_touch"] {
display: none !important;

Seriously…Testing is Important

Above all, when creating any type of interactive functionality, it is crucial to QA and test it. We tested our email live in Samsung Mail, Apple Mail, Outlook 2019 Mac Desktop, Outlook.com web client, and Office 365 web clients. Using Email on Acid and the actual live email client previews to validate the syntax was parsing correctly, we were able to catch an issue with Outlook.com and Office 365. We were also able to render in 98 out of 99 email clients.

And in some of the email web clients where we couldn’t do a live test, we could still see the Animated GIF working. Here’s the example…

Animated GIF for scratch off effect, email coding.

The End Result

EOA's interactive email with a scratch-off present

Pretty amazing huh! No marketing email ever comes easy. There were plenty of last-minute creative changes before we deployed. But through those changes, the core of the code remained the same—a combination of touch to unveil and animated GIF (with fallbacks, of course).

Even Great Emails Need to Be Tested

It’s true: Even well-designed emails can break from time to time. That’s why email testing is an important part of sending a successful campaign. Sinch Email on Acid tests your email code quickly and accurately, allowing you to preview your design across more than 100 of the most popular email clients and devices. Try us free and start delivering email perfection!

Check Out Our Free Trial

19 thoughts on “How to Create a “Scratch Off” Effect in Email HTML”

  1. Is there a view online link for this email? I receive your emails, and have plenty with the christmas gnomes, but not this particular campaign.

    1. Hey James! Thanks for reading our blog. Unfortunately we don’t have a web-based version of the email available. And the contest itself is over. However, you can see the scratch off effect on the hero image of the blog. We may use this same effect on future emails, so stay tuned.

    1. Lori, I’m sorry this didn’t work for you. The coding is geared toward email, but it should work in any browser that supports web kit
      @media screen and (-webkit-min-device-pixel-ratio:0). Hope this helps!

  2. Hi,
    I tried this in one of my emails and it seems to be working, yay! During my testing in Email On Acid i’m seeing either my first image (great) or my fallback (great) but how do i know that the interactivity of clicking on my first image will work to show my second image or not?

    1. Hello Kate. Thanks for reading our blog. To answer your question, my coders tell me to have you test in as many actual email clients as you can to verify.
      Use our platform to test of course, as it does show what image is being displayed, but you’ll also need to test in the actual email clients for verification. Hope this helps.

    1. Deny, that’s awesome! Glad you found our post helpful. We’ll be sharing some more coding tips and tricks from Ed in the upcoming months, so stay tuned.

    1. Liz, I had to reach out to the author for this one. Here’s what Ed said, “Because email technology is old, I have to use old HTML techniques. Without that input type radio button the tap to show effect doesn’t work.” Hope this helps clarify things. Good luck with your coding, and I hope you’re able to create some really amazing scratch-off emails.

  3. Really wish we could see an example of the working code together in an email instead of in pieces. It’s not clear how it all works together.

    1. Hey Matt, The idea here was to break it out into chunks and explain the process for this email. Maybe for the next code-focused blog we do we’ll put all of the code together at the end of it so it’s easier to get

  4. Hi there! This is AWESOME and it works great (for the most part). It tested fine on almost every client I tried. However I did run into a bag with outlook mobile for iOS. The interactive element isn’t responding and the fallback isn’t shown. Instead the “pre-scratch” image shows up and doesn’t allow the user to click to reveal the hidden gif. The best solution I could come up with was to basically rewrite the element without interactivity, hide it then show it in outlook iOS with the [data-outlook-cycle] selector. This seems cumbersome. It’s a lot of redundant code and basically just shows the animated gif on most clients. I was wondering if anyone found a better solution. Note: outlook Mac, web and windows all work great. It’s just a bug on Mobile for iOS. Overall really cool though!!

    1. Thanks for doing a deep dive into this interactive email! So far nobody has mentioned this, or a workaround for it, but we really appreciate you bringing it up and will definitely look into it.

  5. Class “100w” can you please provide the code of it?
    its been used in following img tag

    1. Hey Mounesh – great catch! The class 100w is actually from a previous version of the template and we forgot to remove it from this example. Sorry for the confusion!

    1. Hey Keshav! We’ve all been sitting around scratching our heads over this one (pun intended). It’s such an interesting idea! We haven’t tried it yet, but it’s definitely going on the list of things to test out.

Leave a Reply

Your email address will not be published. Required fields are marked *