How to craft a modern,
mobile-optimized HTML
email template
Jason Samuels, NCFR IT Manager
DrupalCamp Twin Cities – May 2012
Our old email template
Pros
• Simple
• Lightweight
• Worked as
plain-text
• Rendered OK
on mobile
Cons
• Outdated look
• Lots of junk
code = error
characters
• Inconsistent
Our new email template
Pros
• Simple
• Lightweight
• Works as
plain-text
More Pros!
• Preheader text
• Optimized for
mobile (iOS)
• Consistent
with website
• Clean code
• Tested across
How we got there
Three major resources made this possible:
• MailChimp (free templates and guide)
• Cameron Lefevre (NTC session on
optimizing email for mobile)
MailChimp
• Free resources available at:
http://mailchimp.com/resources/
• Email Jitsu guide:
http://mailchimp.com/resources/guides/
email-jitsu
• Free email templates:
http://mailchimp.com/resources/html-email-templates
Theming the template
• Open your website’s Style Guide page, start
Firebug, and start matching elements
• Focus on:
– color
– font-family
– font-size
– font-weight
– line-height
Mobile optimization
• Cameron Lefevre is my hero
• NTEN blog post introducing the issue:
http://www.nten.org/articles/2012/the-
age-of-mobile-email-has-arrived-are-you-ready
• NTC session notes (include code samples):
http://labs.mrss.com/optimizing-email-for-mobile-phones-notes-from-ntc-2012/
CSS3 @media query
By defining alternate styles in
the CSS for devices based on
their maximum screen width,
some elements can be
transformed or hidden to make
for a more user-friendly format
@media screen and (max-width: 600px) { table.emailtable, td.emailcontent { width: 95% !important; } h1, h2, h3, h4 { text-align:center !important; } .nomob { display: none !important; } .headerContent{ text-align:center !important; } a.baemailfooternav { display: block !important; font-size: 14px !important; font-weight: bold !important; padding: 6px 4px 8px 4px !important; line-height: 18px !important; background: #dddddd !important; border-radius: 5px !important; margin: 10px auto; width: 240px; text-align: center; } }
CSS3 @media query
• Defines when mobile styles
get called
• This query applies format on
screens up to 600px wide
• Main table gets re-sized from
600px down to 95% of the
screen’s width
@media screen and (max-width: 600px) { table.emailtable, td.emailcontent { width: 95% !important; } h1, h2, h3, h4 { text-align:center !important; } .nomob { display: none !important; } .headerContent{ text-align:center !important; } a.baemailfooternav { display: block !important; font-size: 14px !important; font-weight: bold !important; padding: 6px 4px 8px 4px !important; line-height: 18px !important; background: #dddddd !important; border-radius: 5px !important; margin: 10px auto; width: 240px; text-align: center; } }
CSS3 @media query
• Header tags and header
content get centered when
viewed on mobile
• nomob is used to hide
elements on mobile
@media screen and (max-width: 600px) { table.emailtable, td.emailcontent { width: 95% !important; } h1, h2, h3, h4 { text-align:center !important; } .nomob { display: none !important; } .headerContent{ text-align:center !important; } a.baemailfooternav { display: block !important; font-size: 14px !important; font-weight: bold !important; padding: 6px 4px 8px 4px !important; line-height: 18px !important; background: #dddddd !important; border-radius: 5px !important; margin: 10px auto; width: 240px; text-align: center; } }
CSS3 @media query
Transforms styling in the footer
navigation when viewed on
mobile. In particular, this code
takes ordinary text links and
turns them into easy-to-press
buttons.
@media screen and (max-width: 600px) { table.emailtable, td.emailcontent { width: 95% !important; } h1, h2, h3, h4 { text-align:center !important; } .nomob { display: none !important; } .headerContent{ text-align:center !important; } a.baemailfooternav { display: block !important; font-size: 14px !important; font-weight: bold !important; padding: 6px 4px 8px 4px !important; line-height: 18px !important; background: #dddddd !important; border-radius: 5px !important; margin: 10px auto; width: 240px; text-align: center; } }