UNPKG

cerberus-email

Version:

A few simple, but solid patterns for responsive HTML email templates and newsletters. Even in Outlook and Gmail.

281 lines (278 loc) 16.5 kB
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Cerberus - Patterns for Responsive HTML Email Templates</title> <link rel="stylesheet" href="assets/cerberus-docs.css"> <link rel="shortcut icon" href="assets/favicon.ico" type="image/x-icon"> </head> <body> <!-- this is the 'docs' version --> <div class="outside title cf"> <div class="inside"> <div class="title-text"> <img src="assets/logo.png" alt="cerberus logo" width="75" height="64"> <h1> <strong>Cerberus</strong> A few simple, but solid patterns for responsive HTML emails. Even in Outlook and Gmail. </h1> <ul class="title-buttons-ul"> <li class="title-buttons-li"> <a href="https://github.com/TedGoas/Cerberus" class="button title-button button-solid"><i class="icon-github-circled"></i> View on GitHub</a> </li> <li class="title-buttons-li"> <a href="https://github.com/TedGoas/Cerberus/archive/master.zip" class="button title-button button-outline">Download Zip</a> </li> </ul> </div> <div class="title-figure"> <img src="assets/phone-outline.png" alt="phone outline"> </div> </div> <div class="blueprint"></div> </div> <div class="outside body"> <div class="inside cf"> <div class="toc"> <div class="toc-padding"> <ul class="toc-ul"> <li class="toc-li"> <a href="#intro" class="toc-a">Introduction</a> </li> <li class="toc-li"> <a href="#things" class="toc-a">Things to know</a> </li> <li class="toc-li"> <a href="#templates" class="toc-a">The templates</a> </li> <li class="toc-li small"> <a href="#fluid" class="toc-a">Fluid Template</a> </li> <li class="toc-li small"> <a href="#responsive" class="toc-a">Responsive Template</a> </li> <li class="toc-li small"> <a href="#hybrid" class="toc-a">Hybrid Template</a> </li> <li class="toc-li small"> <a href="#archived" class="toc-a">/archived-versions/</a> </li> <li class="toc-li"> <a href="#support" class="toc-a">Client Support</a> </li> <li class="toc-li"> <a href="#css-inliners" class="toc-a">CSS Inliners</a> </li> <li class="toc-li"> <a href="#contribute" class="toc-a">Contributing</a> </li> <li class="toc-li"> <a href="#credits" class="toc-a">Resources</a> </li> <li class="toc-li"> <a href="#author" class="toc-a">Author</a> </li> </ul> </div> </div> <div class="sections"> <blockquote> <p>Cerberus - <br> Between mobile, Gmail, and Outlook, HTML email is a three-headed dog from hell. </p> </blockquote> <div class="section" id="intro"> <h2>Introduction</h2> <p>Coding regular emails is hard enough by itself. Making them responsive shouldn't add to the headache. A few simple, but solid patterns are all that's needed to optimize emails for small screens.</p> <p><strong>That's what Cerberus is.</strong> <p>It's just a few responsive email patterns that go a long way. The code blocks are compartmentalized so they may be used, removed, combined, and nested to build an email.</p> <p>Each template contains code comments and has good support among popular email clients.</p> <p>I <a href="http://www.tedgoas.com/blog/cerberus-responsive-email-templates/">wrote a blog post</a> that goes into more detail on why I made this in the first place. Cerberus is <a href="https://github.com/TedGoas/Responsive-Email-XX">Responsive Email XX</a>'s successor.</p> </div> <div class="section" id="things"> <h2>Things To Know</h2> <ul> <li>Cerberus is a small collection layout patterns for HTML email. The code is meant to be edited, adapted, and built upon.</li> <li>The code is compartmentalized and annotated in an effort to explain what’s happening so you can add, edit, and remove code with some confidence.</li> <li>This has been tested in all “popular” email clients, but not every email client out there. <a href="#support">More on that here</a>.</li> </ul> </div> <div class="section" id="templates"> <h2>The Templates</h2> <div id="fluid" class="cf"> <figure class="figure-wireframe"> <img src="assets/wireframe-fluid.png" width="800" height="425" class="figure fluid"> <span class="caption">As the layout narrows, the email content reflows and resizes gracefully.</span> </figure> <h3>Fluid Template</h3> <p>Good for simple layouts such as transactional and single column emails.</p> <p>This template focuses on a fluid layout that sizes itself using percentage-based widths to shrink horizontally on narrow screens. This email layout does not reconfigure at different screen sizes.</p> <p>If you want a basic template to handle rich text and images, this is a good baseline.</p> <ul class="buttons-ul"> <li class="buttons-li"> <a href="http://htmlpreview.github.io/?https://github.com/TedGoas/Cerberus/blob/master/cerberus-fluid.html" class="button sections-button button-solid">View A Demo</a> </li> <li class="buttons-li"> <a href="https://raw.githubusercontent.com/TedGoas/Cerberus/master/cerberus-fluid.html" class="button sections-button button-outline"><i class="icon-code"></i> View Raw</a> </li> </ul> </div> <hr> <div id="responsive" class="cf"> <figure class="figure-wireframe"> <img src="assets/wireframe-responsive.png" width="800" height="425" class="figure fluid"> <span class="caption">The email layout changes at breakpoints using media queries.</span> </figure> <h3>Responsive Template</h3> <p>Good for more complicated, shape-shifting email layouts that work on <em>some</em> mobile clients.</p> <p>This template uses media queries to reconfigure the layout for different screen sizes for email clients that support media queries. However, mobile clients that don’t support media queries or the <code>&lt;style&gt;</code> tag will display a shrunk version of the desktop layout instead. This applies to some versions of Gmail&nbsp;(<a href="https://litmus.com/blog/gmail-to-support-responsive-email-design">still</a>) and Yahoo, as well as a number of international email clients (<a href="https://emails.hteumeuleu.com/should-we-stop-inlining-styles-in-emails-8c3b64f0d407#.57mlzfimq">more info on that here</a>).</p> <p>If you’re already comfortable with media queries, the learning curve is relatively low. If total device coverage isn’t required, you can create a responsive email the same way you create a responsive website.</p> <ul class="buttons-ul"> <li class="buttons-li"> <a href="http://htmlpreview.github.io/?https://github.com/TedGoas/Cerberus/blob/master/cerberus-responsive.html" class="button sections-button button-solid">View A Demo</a> </li> <li class="buttons-li"> <a href="https://raw.githubusercontent.com/TedGoas/Cerberus/master/cerberus-responsive.html" class="button sections-button button-outline"><i class="icon-code"></i> View Raw</a> </li> </ul> </div> <hr> <div id="hybrid" class="cf"> <figure class="figure-wireframe"> <img src="assets/wireframe-hybrid.png" width="800" height="425" class="figure fluid"> <span class="caption">The email layout stacks without media queries.</span> </figure> <h3>Hybrid Template</h3> <p>This template uses a hybrid approach to reconfigure the layout for different screen sizes for email clients regardless of media query support. At its core, it uses max-width and min-width to impose rigid baselines (allowing some movement) and imposes a fixed, wide width for Outlook who is shackled to desktop anyway. Once a mobile-friendly baseline is set, media queries progressively enhance the email further in clients that support it.</p> <p>If you have some email design experience, this template optimizes every popular email client. All the extra Outlook code can make these templates quite large and your maths have to be spot on for multi-column layouts.</p> <ul class="buttons-ul"> <li class="buttons-li"> <a href="http://htmlpreview.github.io/?https://github.com/TedGoas/Cerberus/blob/master/cerberus-hybrid.html" class="button sections-button button-solid">View A Demo</a> </li> <li class="buttons-li"> <a href="https://raw.githubusercontent.com/TedGoas/Cerberus/master/cerberus-hybrid.html" class="button sections-button button-outline"><i class="icon-code"></i> View Raw</a> </li> </ul> </div> <hr> <div id="archived" class="cf no-figure"> <h3>/archived-versions/</h3> <p>Templates in the <code>archived-versions</code> folder are not currently being maintained and should be considered <strong>unsupported and deprecated</strong>. They are kept around for historical purposes. 💫</p> </div> </div> <div class="section" id="support" data-scroll-index="4"> <h2>Client Support</h2> <p>Cerberus is tested in the most popular email clients <a href="http://emailclientmarketshare.com/">as reported by Litmus</a> and my own email campaigns. I've focused on the following clients:</p> <div class="row cf"> <ul class="col-1-3"> <li class="li-title">Desktop</li> <li>Outlook 2000/02/03/07/10/13/16 (Windows)</li> <li>Windows 10 Mail</li> <li>Outlook 2011/16 (Mac)</li> <li>Apple Mail 9/10</li> <li>Thunderbird</li> </ul> <ul class="col-1-3"> <li class="li-title">Web (Chrome, <abbr title="Firefox">FF</abbr>, <abbr title="Internet Explorer">IE</abbr>)</li> <li>Gmail (IMAP, Business</li> <li>Outlook.com</li> <li>Yahoo</li> <li>Aol</li> <li>Office 365 Web</li> <li>Comcast</li> <li>Web.de</li> <li>GMX.de</li> <li>freenet.de</li> <li>T-Online.de</li> <li>Mail.ru</li> <li>Terra Mail</li> </ul> <ul class="col-1-3"> <li class="li-title">Mobile Apps</li> <li>iOS Mail (iPhone 5 and up, iPad, iPad Mini)</li> <li>Gmail (iOS+Android, all account types)</li> <li>Google Inbox (iOS)</li> <li>Mail (Android 6.0)</li> <li>Yahoo (iOS)</li> <li>Outlook (iOS)</li> <li>Alto Mail (iOS)</li> </ul> </div> <p class="warning">When I say “tested”, I mean “email doesn’t fall apart”. I don't mean "Everything is pixel perfect in Outlook" or “I found a way to make media queries work everywhere.” They don't.</p> <p class="warning">There are multiple versions of Gmail. Cerberus works pretty well in all of them. Rémi Parmentier created <a href="https://cdn-images-1.medium.com/max/1400/1*JGe_A7b8LiHZfeSGzNZE9w.png">an excellent graphic</a> explaining Gmail's capabilities in <a href="https://emails.hteumeuleu.com/trying-to-make-sense-of-gmail-css-support-after-the-2016-update-53c15151063a">this article</a>.</p> <p>Any client not listed above should be considered untested. If you feel I’ve left out a popular email client or can suggest a non-destabilizing fix for one, please <a href="https://github.com/TedGoas/Cerberus/issues">submit an issue</a>!</p> <p>For what it's worth, Litmus (who <em>does</em> test every email client) includes Cerberus in its <a href="https://litmus.com/email-builder">Email Builder</a>, so there’s that.</p> </div> <div class="section" id="css-inliners"> <h2>A Word on CSS Inliners</h2> <p>I recommend <strong>against using a CSS inliners</strong> with Cerberus. Here’s why:</p> <ul> <li>Cerberus is supposed to be simple and should not require a dependency like a CSS inliner.</li> <li>The placement of Cerberus’s CSS is already optimized. The CSS in the <code>&lt;head&gt;</code> is meant only for email clients that parse CSS in this location. It doesn’t need to be inlined.</li> <li>There are some CSS selectors like <code>:hover</code> that don’t inline so well and throw errors in some CSS inliners.</li> <li>Inlining leads to code bloat. Not only does this impact download speeds, but some email clients like Gmail and iOS Outlook truncate messages after they exceed a certain file size.</li> </ul> <p>I’m a fan of using snippets, available most code editors. I understand CSS inliners help many folks, but if you use one with Cerberus, please do so at your own risk. I recommend <a href="https://htmlemail.io/inline/">Lee Munroe's CSS inliner</a> and here good things about <a href="https://github.com/Mange/roadie">Roadie</a>.</p> </div> <div class="section" id="contribute"> <h2>Contributing</h2> <p>If you would like to help, please <a href="https://twitter.com/tedgoas">@reply me on Twitter</a> or <a href="https://github.com/TedGoas/Cerberus/issues">open an issue</a> to discuss your idea. I'm forever interested in reducing the entropy of this code. I'm most interested in:</p> <ul> <li>Fixing existing code that's broken.</li> <li>Reducing the amount of code in existing patterns.</li> <li>Improving the documentation.</li> </ul> <p>Please be mindful there are <strong>three templates</strong> that share a lot of code. Many changes apply to all three.</p> </div> <div class="section" id="credits"> <h2>Resources</h2> <p>Things that directly helped (and continue to help) build Cerberus.</p> <div class="row cf"> <div class="col-1-2"> <ul> <li class="li-title">Common Guidelines</li> <li><a href="http://www.campaignmonitor.com/css">CSS Support in Email</a></li> <li><a href="http://blog.fogcreek.com/responsive-html-emails-a-different-strategy/">Responsive HTML Emails: a Different Strategy</a></li> <li><a href="https://github.com/fcarneiro/tedc15_template">Fabio Carneiro's TEDC15 talk files</a></li> <li><a href="http://labs.actionrocket.co/the-hybrid-coding-approach">The Hybrid Coding Approach</a></li> <li><a href="http://webdesign.tutsplus.com/tutorials/creating-a-future-proof-responsive-email-without-media-queries--cms-23919">Creating a Future-Proof Responsive Email Without Media Queries</a></li> <li><a href="http://ryanfield.ca/fly-brid/">Fly-Brid Email Generator</a></li> </ul> </div> <div class="col-1-2"> <ul> <li class="li-title">Other Resources</li> <li><a href="https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design">Bulletproof Buttons</a></li> <li><a href="http://backgrounds.cm/">Bulletproof Background Images</a></li> <li><a href="https://litmus.com/blog/understanding-responsive-and-hybrid-email-design">Understanding Responsive and Hybrid Email Design</a></li> <li><a href="http://blog.rebelmail.com/accessibility-in-email-part-ii/">Accessibility in email</a></li> <li><a href="https://drive.google.com/open?id=0B2uzG2bvD431aWsyTXRnVG94S3c">Rob Berinti's TEDC '15 talk on Typography</a></li> <li><a href="https://email.geeks.chat/">#emailgeeks Slack group</a> </ul> </div> </div> </div> <div class="section" id="author"> <h2>Author</h2> <p>Hello! I’m Ted Goas, the core author and maintainer. I'm a designer &amp; front-end developer working on websites, web apps, and HTML emails. And I enjoy talking shop on Twitter.</p> <p><a href="https://twitter.com/TedGoas" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @TedGoas</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></p> </div> </div> </div> </div> <script src="http://code.jquery.com/jquery-2.2.0.min.js"></script> <script src="assets/scrollIt.js"></script> <script src="assets/jquery.sticky.js"></script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-3248378-4', 'auto'); ga('send', 'pageview'); </script> </body> </html>