Introducing the Filmstrip Interactive Email Technique
Table of content
-
01
Windowed Named Anchors - Use 'name' and not 'id'
-
02
Support in Email Clients -
03
Advantages - Supported in major mobile email clients.
- Simple
- No CSS needed
- Better ESP support
-
04
Limitations - Lack of support in desktop and webmail.
- Not as flexible as the checkbox technique
- Container scrolls to the top of window in Android
-
05
Tabs Example -
06
Interactive Support Detection and Fallback - Adding vertical space in Android
-
07
Filmstrip+ and Next Steps - Don’t Guess, Test!
Windowed Named Anchors
The simplicity of the filmstrip technique lies in the use of named anchors. Yes, those a tags containing a name attribute that allow you to jump from one part of an email to the next.<a href="#foo">Click here</a>
<a name="foo"></a>
Content here...
By stacking blocks or frames of content separated by named anchors and placing them within a container that is sized to show only a single frame, you can display any frame by referencing the anchor name in a link.
Think of it like a strip of film. Remember those rolls of celluloid you capture photos with before the advent of digital cameras? Well in our case we capture the state of each interaction as a frame in a vertical strip that we selectively display in the email client.
Normally, named anchors are used to segment content in an email and clicking on a link that refers to a named anchor will scroll the email to the location of the anchor. However since these anchors are hidden inside a container, clicking on a link referring to a hidden anchor has the effect of shifting the frame into view.
Strangely, although regular named anchors don't work in the iOS email client, they work when placed within a "window".
<a href="#f1">One</a>
<a href="#f2">Two</a>
<a href="#f3">Three</a>
<div style="overflow:hidden;width:200px;height:100px;">
<a name="f1"></a>
<div style="height:100px;">Frame 1</div>
<a name="f2"></a>
<div style="height:100px;">Frame 2</div>
<a name="f3"></a>
<div style="height:100px;">Frame 3</div>
</div>
View example on Codepen
Use 'name' and not 'id'
Although the name attribute in anchors are technically deprecated in HTML5 in favor of simple ids, they still work in modern browsers. This technique will not work in the Gmail App if your link refers to an id instead of a name.Support in Email Clients
Update: Unfortunately due to a Gmail Android update, this technique no longer works on that client. The following table lists the email clients that this technique will work in. For the clients that don't support this technique, you'll need to ensure you have an alternative or fallback design to display in the other clients. Here's where Email on Acid comes in handy. Email on Acid's email testing lets you quickly see which of the dozens of email clients are rendering your fallback vs interactive design and if something is not looking right.Windowed Name Anchor Support | |
---|---|
Android 4.4 Native Client | |
AOL Mail | |
Apple Mail | |
Gmail App (Android) | |
Gmail POP/IMAP * (Android) | |
Gmail Webmail | |
iOS Mail | |
Outlook (Mac/Windows/iOS/Android) | |
Outlook.com Webmail ** | |
Samsung Native Client | |
Yahoo! Mail App (iOS/Android) | |
Yahoo! Webmail** |
Advantages
Supported in major mobile email clients.
Now you'll be able to design interactivity that the majority of users of email clients on iOS and Android can see. This technique works in the Gmail app for Android, Android 4.4 and Samsung native clients. This technique won't work in the Outlook, Yahoo! Mail and Gmail iOS apps as well as the Gmail Android app when set up with a non-Gmail account.Simple
No more long chains of checked and sibling selectors to deal with, it's just links and named anchors.No CSS needed
You still need CSS to style your email, but all the interactivity lies completely in HTML making the coding process straightforward. Although CSS is used to detect and control when to show the interactive and fallback versions, that code shouldn't need to be changed between designs.Better ESP support
Some email service providers (ESP) *ahem MailChimp!* strip checkbox and radio elements in emails which limited their customers' ability to send interactive email. Since this method only uses anchors, customers of these ESPs can finally send interactive email.Limitations
There's often tradeoffs when it comes to email design and this is no exception.Lack of support in desktop and webmail.
Although regular named anchors work in Gmail webmail, this technique does not work in Gmail webmail. Apple Mail and Outlook for Mac supports the older checkbox technique but this technique won't work in it. A follow up article will show ways to get support on the Mac using a combination technique.Not as flexible as the checkbox technique
The simplicity of the technique can also be a limitation. This filmstrip technique true to its namesake requires that all the interactive frames be of the same size. However, you can use media queries to create different fixed dimensions based on the size of the screen of the client (such as between tablet and mobile). Another feature of the checkbox technique is that you can toggle the display and hiding of elements such as a hamburger menu using the state of the checkbox. (I am experimenting with some techniques to achieve the same effect with the filmstrip technique).Container scrolls to the top of window in Android
In Android clients (Gmail, Inbox, Samsung and Android 4.4) when the recipient triggers an anchor, the email client will scroll the email so the the new frame is displayed right below top of the message window. So if your trigger links are above the container, the recipient will need to scroll your container down each time the recipient wants to click on a different link. In the Inbox App, the container will also be slightly obscured by the toolbar when the container is shifted. The detection and fallback code we will use will exclude the Inbox App.Tabs Example
The following is an implementation of interactive tabs using the filmstrip technique. View example The tabs are styled links that link to named anchors above the individual frames. Instead of placing the tabs at the top of the container, the tabs are included inside every frame. This technique allows you to easily highlight the active tab and address the scroll issue that was mentioned earlier.Interactive Support Detection and Fallback
We want to show a different block of content for clients that don't support windowed named anchors. We begin by showing the fallback by default and hiding the interactive content.<!--[if !mso]><!-->
<div class="interactive" style="display:none;max-height:0;overflow:hidden;">
INTERACTIVE CONTENT (PUT FILMSTRIP CODE HERE)
</div>
<!--<![endif]-->
<div class="fallback">
FALLBACK CONTENT
</div>
Then with CSS and media queries we can selectively enable interactivity only for supported clients. First we enable interactivity in iOS 10+ Mail clients using a @supports technique discovered by Rémi Parmentier. Note because Gmail strips out style blocks containing @supports, it needs to be placed in its own <style> block.
@supports (-webkit-overflow-scrolling:touch) and (color:#ffff) {
...
}
Next we enable interactivity by targeting Gmail and Inbox apps in Android. We do this by using a Gmail targeting technique pioneered by Mark Robbins that only targets the Gmail Android client. (I'm using a shortcut that requires you to not use the <u> tag in your email content).
/* This technique no longer works in Gmail on Android as of Nov 2017 */
/*
div > u ~ div .interactive{
display:block !important;
max-height:none!important;
}
div > u ~ div .fallback{
display:none!important;
}
*/
And finally we add the Samsung email client by targeting its unique container id of #MessageViewBody.
Verifying which version shows up on which email client can be a really tedious process. Email on Acid's email testing can help save you hours when building interactive designs as you'll be able to quickly see the impact of your code changes in over 60 different email clients in a single test.
The resulting interactive detection code below should be placed in the <head>:
<style>
/* Using @supports to ONLY target iOS Mail 10+ */
@supports (-webkit-overflow-scrolling:touch) and (color:#ffff) {
div[class^=interactive]{
display:block !important;
max-height:none!important;
}
div[class^=fallback]{
display:none!important;
}
}
</style>
<style>
/*
Enable for Gmail on Android
This no longer works as of Nov 2017
*/
/* div > u ~ div .interactive{
display:block !important;
max-height:none!important;
}
div > u ~ div .fallback{
display:none!important;
}
*/
/* Enable for Samsung App */
#MessageViewBody .interactive{
display:block !important;
max-height:none!important;
}
#MessageViewBody .fallback{
display:none!important;
}
</style>