HTML emails are funny… most modern web browsers fully support standard XHMTL 1.0/CSS2.1 when displaying web pages. Email clients, such as Outlook and Entourage, even in their most recent versions, are not nearly so compliant. Furthermore, many web based email clients strip out a lot of markup before they display HTML emails, which means your carefully crafted design may be bastardized in any number of different ways.
Here are a number of tips & tricks that help get things through unmolested. These are current as of April 2010.
<div>
s less so. If you're doing something REALLY simple, you might be able to get away with a positioned <div>
.<style>
tag). The annoying thing about this is that it means you have to repeat your styles over and over again, but it's better than not having your email show up properly. div
that sits right inside the body and has your background color:<body style="margin:0;padding:0;"> <div id="BodyImposter" style="margin:0;padding:0;width:100%;color: #2c2c2c; background-color: #2c2c2c;"> content goes here </div> </body>
Mailto:
links (e.g. <a href='mailto:bob@bobsmith.com'>Mail Bob Smith</a>
) do work in emails, but they'll open whatever the default mail client is on your recipient's machine. That can be a little disconcerting for users if they are, for example, reading your message in their Gmail account, click a mailto:
link, and it opens their Outlook 2007 for work. Use them, but use them with caution.®
for ®, instead of inserting the characters directly. Most email clients theoretically support UTF-8, allowing for direct insertion of characters like ®, but best to play it safe.When doing the text version, please visit:
®
with (R)
, ©
with (C)
, ™
with (TM)
, etc.Click Here
with Please Visit: {URL}
It somewhat goes without saying these days, but host the images for your email on your website. Don't attach them to the email itself. Here are some tips for how to best host them:
'header_072808.gif
' rather than 'header.gif
'. Otherwise, when people go to look at your email a year later and you've changed or moved the image, it will look funny./images/foo.gif_081308.gif
, and then you decide to store all your images in an img
folder (instead of images
) all those old emails will break./emails/newsletter_030410/images/header.gif /emails/newsletter_031510/images/header.gif /emails/newsletter_041010/images/header.gif
width
and height
, particularly on images. Most mail clients don't download images by default, and if you don't assign a width
and height
, they won't lay your message out properly until the user clicks 'download images' (which they may never do).Don't use any JS / Forms / Flash. Most mail clients block all rich media (e.g. flash) as well JavaScript and form submissions. Link to forms on your website, and just deal without JS & flash.
As of August 2008, Gmail and Outlook 2007 (which uses the Word rendering engine) are the worst email clients. If you can get it to work in those, it will probably work most anywhere else without too many tweaks.
Your email may be read in any mail client, so you'll probably want to pay attention to all of these.
<p>
spacing; you need to set<style> p { margin-bottom: 1em; } </style>
(Incidentally, Yahoo Mail does understand inline style sheets, which is why you can use one here even though the advice above says not to use them)