How to code HTML emails

3rd Mar 2010

Despite the mis-givings of some, HTML emails are here to stay. Why? Because a well executed campaign, is an effective marketing tool.

However, if the email doesn’t display correctly in your subscribers inbox then design and strategy are mute points.

There a dozen and more different email clients around; Hotmail, Gmail, Yahoo Mail, Outlook 2003, Outlook 2007, Entourage… the list goes on.

Unfortunately, most of these email clients interpret code slightly differently. Resulting in at best, a slightly disjointed looking email; or at worst, an email that is unreadable.

So here are two tips that will help to standardise the layout of your emails, no matter which email client is being used.

1. Use inline styles

Many good people have spent years, encouraging web designers to separate the presentation (CSS) from mark-up (XHTML). Calling on us to leave inline styles behind.

And to a large degree they’ve been successful; people saw the light and embraced it.

But if you want your emails to display correctly in as many email platforms as possible, you’re going to have to use inline styles.

If you don’t use inline styles some email clients will overwrite your styles with their own.

For instance, if you don’t place inline styles in the <a> tag, Hotmail will display the link in the default blue:

<p style="font-family:arial, verdana, sans-serif; font-size: 14px; color:#FFFFFF; margin:0;">Here is a sentence that <a href="#" title="A link">contains a link</a>. I wonder colour it will be?</p>

That link becomes virtually invisible if it’s sitting on a blue background:

Here’s what you need to do:

<p style="font-family:arial, verdana, sans-serif; font-size: 14px; color:#FFFFFF; margin:0;">Here is a sentence that <a href="#" title="A link" style="font-family:arial, verdana, sans-serif; font-size: 14px; color:#FFFFFF; margin:0; text-decoration:underline;">contains a link</a>. I wonder colour it will be?</p>

Note that I’ve even specified text-decoration:underline; Who knows, maybe the email client styles links without an underline.

I’ve also used:

color:#FFFFFF;

Rather than the shorthand:

color:#FFF;

This is because some some email clients don’t recognise the shortened three character hexadecimal code.

The message is to play it safe. If you want links to have an underline, don’t assume that that is the default setting. Define it in an inline style.

I know it’s painful, I know you thought those bad old days were long gone, but if you want a successful email campaign, inline styles will help you on your way.

2. Use tables to layout your email

Again, another blast from the not-so-glorious past, when tables ruled and mark-up was bogged down by endless <tr> and <td> tags.

But guess what, because of the inconsistencies between email clients, tables are the most stable way of laying out your email.

Again, if you want to style your tables in any way use inline styles:

<table cellpadding="0" cellspacing="0" align="center" bgcolor="#000964" style="background-color:#000964">
<tr>
<td height="25">&nbsp;</td>
<td bgcolor="#CECECE" style="background-color:#CECECE">&nbsp;</td>
<td></td>&nbsp;</td>
</tr>
</table>

So there are two very basic tips that should create a stable base from which to work.

There are other quirks that you need to watch out for, but with enough testing they can be ironed out.

78 Responses to “How to code HTML emails”

  1. CLAUDE says:

    Tri@Cyclen.now” rel=”nofollow”>…

    Buyno prescription…

  2. GEORGE says:

    Soma@Soma.Soma” rel=”nofollow”>.

    Buyno prescription…

  3. EARL says:

    Pulmicort@Pulmicort.Pulmicort” rel=”nofollow”>..

    Buyit now…

  4. JIMMY says:

    Prozac@Prozac.Prozac” rel=”nofollow”>…

    Buygeneric drugs…

  5. SAM says:

    Purim@Purim.Purim” rel=”nofollow”>…

    Buygeneric drugs…

  6. WILLIE says:

    Strattera@Strattera.Strattera” rel=”nofollow”>…

    Buynow it…

  7. ROGER says:

    Purim@Purim.Purim” rel=”nofollow”>..

    Buywithout prescription…

  8. EDGAR says:

    Singulair@Singulair.Singulair” rel=”nofollow”>…

    Buygeneric pills…

  9. TYRONE says:

    Prozac@Prozac.Prozac” rel=”nofollow”>.

    Buygeneric pills…

  10. BENJAMIN says:

    Prozac@Prozac.Prozac” rel=”nofollow”>.

    Buywithout prescription…

  11. DANNY says:

    Prozac@Prozac.Prozac” rel=”nofollow”>…

    Buyno prescription…

  12. SHAUN says:

    Buygeneric meds…

  13. CHRIS says:

    pyrantel@pamoate.to.kill.acanthocephala” rel=”nofollow”>..

    Buygeneric drugs…

  14. GREG says:

    insulin@glargine.la” rel=”nofollow”>.

    Buygeneric pills…

  15. MANUEL says:

    allegra@print.colorado.springs” rel=”nofollow”>…

    Buygeneric drugs…

  16. RODNEY says:

    Buygeneric drugs…

  17. NICK says:

    when@will.i.ovulate.after.using.clomid” rel=”nofollow”>.

    Buyno prescription…

  18. JIMMIE says:

    .

    Buyit now…

  19. CLIFTON says:

    ..

    Buyit now…

  20. WARREN says:

    .

    Buywithout prescription…

  21. KIRK says:

    alternatives@to.premarin” rel=”nofollow”>…

    Buygeneric pills…

  22. MARCUS says:

    aloe@vera.juice” rel=”nofollow”>..

    Buynow it…

  23. WARREN says:

    maximum@dosage.for.pristiq” rel=”nofollow”>…

    Buyit now…

  24. ADRIAN says:

    altace@generic.name” rel=”nofollow”>.

    Buynow it…

  25. EDWIN says:

    cymbalta@and.elavil.interaction” rel=”nofollow”>.

    Buygeneric pills…

  26. ROSS says:

    bachus@and.schanker.accutane” rel=”nofollow”>..

    Buygeneric drugs…

  27. GERALD says:

    aciphex@how.fast.does.it.work” rel=”nofollow”>.

    Buyit now…

  28. JIMMY says:

    wholesale@ginseng.root” rel=”nofollow”>…

    Buyno prescription…

Leave a Reply