Quick Nav
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 June 2008.
<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>
'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.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).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)
Discussion