Best practices for styling HTML emails [closed]
I'm designing an HTML template for an email newsletter. I've learned that many email clients ignore linked stylesheets, and many others (including Gmail) ignore CSS block declarations altogether. Are inline style attributes my only choice? What are the best practices for styling HTML emails?
I've fought the HTML email battle before. Here are some of my tips about styling for maximum compatibility between email clients.
Inline styles are you best friend. Absolutely don't link style sheets and do not use a
<style>
tag (GMail, for example, strips that tag and all it's contents).Against your better judgement, use and abuse tables.
<div>
s just won't cut it (especially in Outlook).Don't use background images, they're spotty and will annoy you.
Remember that some email clients will automatically transform typed out hyperlinks into links (if you don't anchor
<a>
them yourself). This can sometimes achieve negative effects (say if you're putting a style on each of the hyperlinks to appear a different color).Be careful hyperlinking an actual link with something different. For example, don't type out
http://www.google.com
and then link it tohttps://gmail.com/
. Some clients will flag the message as Spam or Junk.Save your images in as few colors as possible to save on size.
If possible, embed your images in your email. The email won't have to reach out to an external web server to download them and they won't appear as attachments to the email.
And lastly, test, test, test! Each email client does things way differently than a browser would do.
Campaign Monitor have an excellent support matrix detailing what's supported and what isn't among various mail clients.
You can use a service like Litmus to view how an email appears across several clients and whether they get caught by filters, etc.
Mail chimp have got quite a nice article on what not to do. ( I know it sounds the wrong way round for what you want)
http://kb.mailchimp.com/article/common-html-email-coding-mistakes
In general all the things that you have learnt that are bad practise for web design seem to be the only option for html email.
The basics are:
- Have absolute paths for images (eg. https://stackoverflow.com/random-image.png)
- Use tables for layout (never thought I'd recommend that!)
- Use inline styles (and old school css too, at the very most 2.1, box-shadow won't work for instance ;) )
Just test in as many email clients as you can get your hands on, or use Litmus as someone else suggested above! (credit to Jim)
EDIT :
Mail chimp have done a great job by making this tool available to the community.
It applies your CSS classes to your html elements inline for you!