email-illustration

HTML Email Development Tips & Guide

Introduction

HTML email marketing has been around for a long time. 5 years ago I thought we would have seen a decline in the area, due to social media and other advertising platforms. If anything however, the opposite is true and I see more and more clients wanting to send out engaging email campaigns. In fact, a recent study shows email as the most preferable method of receiving marketing messages

Let’s face it, creating HTML emails that are consistent across the majority of email platforms can be a nightmare, with many email programs (Microsoft in particular) having a general disregard of web standards. Developing for the web compared to HTML email development is a world apart… we basically need to disregard our modern, good coding practices and resort to dirty, depreciated HTML that should otherwise live in the last decade.

There are a number of guides, tips and topics on this subject but I’ve pulled together a load of my top tips and bug fixes, largely from a development point of view. I’m a web developer at a design agency and we spend a lot of time creating rich HTML emails with complex designs. These HTML email development tips have been tested on the majority of email programs including Outlook 2007, Outlook 2003, Thunderbird, Apple Mail (Mac and iPhone), Hotmail, Yahoo and GMail.

General HTML Email Development Tips

Use Tables
Forget the standard DIVs and CSS approach for the main layout of your HTML email. Tables and multi-level nested tables are the way to go and there seems to be no limit on the levels of nested tables, so don’t be afraid to use them despite how counter-intuitive it may seem. Divide your design up into rows and columns as you may have (like me) when first learning web development.

If you want to centre the email horizontally, the best method is to create a master table with 1 cell and set it to 100% width and centre align another table within. If you want a background colour, it’s best the background colour within your 100% table as well (using td bgcolor=”#FFFFFF”), since some web clients will strip it out of the body tag.

You can also make full use of “td height”. The table cell height element, despite being depreciated, is supported in all email programs capable of HTML. For example, an empty table cell (such <td>&nbsp</td>) will get ignored in most email programs, but not if you give it a height: <td height="18">&nbsp</td>

Use in-line CSS
Forget loading external style-sheets or embedding CSS within the header, these approaches have limited support and many webmail services including GMail will strip out CSS from the header. Use standard in-line CSS everywhere – every new paragraph, every header, every link etc. Sure, it’s a hassle but it’s what is needed for the best cross client support.
A typical paragraph tag for example may look like:

<p style="font-family:Verdana, Geneva, sans-serif;font-size:11px;line-height:18px;color:#575756;padding:0px;margin:0px;margin-bottom:15px;">

Note as well the use of the full 6 character color hex code, rather than the 3 character shortened version.

Dimensions
Typically most email programs have some sort of navigational panel on the left, so for standard (lowest common denominator) monitor resolutions of 1024×768, this will  leave around 600 pixels real estate to play with. Height is less of an issue, but good to keep the most important elements within 300-400 pixels of the height to avoid needing to scroll to see them.

Design
Although entirely possible to implement really complex designs, the more complex the design, the longer it takes to develop, test and create cross-compliant HTML emails. I would estimate about double the code is required in creating a HTML email over the equivalent web page design. One thing that can really add to the development time for HTML emails is the use of rounded corners and drop shadows on boxes.. since we cannot use CSS3 rounded corder property for example, we need to splice up each rounded corner element into multiple graphics.

A good thing to bear in mind is the fact that images will not be displayed straight away and most email clients will have some sort of ‘download images’ button. I often try and recommend to get some plain text, including any USPs inside the first 300-400 pixels email height.

Try to keep a high text to image ratio, emails heavy on images which have little to no plain text will be more likely to get blocked by SPAM filters.

Be wary of custom line breaks. Before you start adding specific line breaks to paragraph text, it’s worth considering the fact that different machines and email clients render fonts very slightly differently. In addition, iOS devices will automatically increase font sizes below 13pts for better display, so custom line breaks can really mess up your design as they will look like they are appearing in the wrong places.

Animation
Although HTML5 video has some support within newer email programs such as Apple Mail and Thunderbird, most types of animations will be stripped out including JavaScript and Flash. The exception to this are animated GIFs which can really help add engagement to HTML emails.

Animated GIFs should be small in (physical) size and will work best with a small colour palette – you can achieve quite a few frames of animated text on a plain background for example.

Test to destruction
I have a number of email addresses setup primarily used for testing purposes. While there are a number of emulators out there, I find it’s often best (and quicker) to stay logged into numerous email programs and I usually test on Apple Mail (mac & iPhone), Outlook, Thunderbird, GMail and Hotmail

3rd party email services
I once created my own bulk emailing script but it was a hassle and had very limited functionality. Email marketing services such as MailChimp and YMLP let you upload your HTML email, send to thousands of users at relatively low cost and provide good reporting tools such as open and click rates, graphs and click maps (which display a visual of your email overlaid with click statistics). MailChimp is fairly strict in who it allows you to email and encourages only users who have opted-in to receive communication. YMLP on the other hand is more flexible in that respect.

HTML Email Forwarding
When a HTML email is forwarded, the results from the new recipient cannot be guranteed as many email clients will strip out most of your nice clean code and try and replace it with their own. Thunderbird seems pretty good at keeping the layout, Outlook (as you might expect) is terrible at retaining formatting.

Text Formatting

Getting the right formatting for text, including spacing and colours can be one of the most frustrating aspects of HTML email development. The below techniques are some of the more frequently occurring tips to get text in HTML emails to display consistently.

Line and paragraph spacing
One of the most frustrating things I used to find about HTML email development is the wide variation in how different email clients treat margin, padding and line spacing. Not all margin and paragraph styles are supported and Hotmail for example only supports margin-bottom. Therefore, for each paragraph tag I usually add styles that look like this:
<p style="padding:0px;margin:0px;margin-bottom:15px;line-height:18px;">

Use Web Friendly Fonts
Nope, you can’t use @font-face, or cufon, or any other font replacement method to get non-standard web fonts to work cross-platform. So your choices are either to use web friendly fonts or embed fonts in images. I sometimes use a mix of both, for example having paragraph fonts in plain text and large headings or banner text as embedded font.

Forget sub headings
For some reason, Hotmail doesn’t like custom colour styling for H2, H3, H4, H5, H6 heading tags. You can fix this by using !important in the in-line style but this messes up the colour in Outlook. Best way I’ve found is to either use H1 or the p tag for all headings or use have a <span%gt; style within.

Formatting Links
Include in-line CSS within link tags as well, so they don’t get replaced by the default blue. For example <a style="color: #e1e1e1;" href="http://www.example.com/">view website</a>. Unfortunately you cannot use the hover style in-line, so if you want a hover over style you can add it within the tag but this will get stripped out of many email clients and I usually don’t bother with it.

Formatting Bullets
Outlook 2010 doesn’t like bullets in HTML emails, it chooses to disregard them completly. So forget using
<ul><li>in HTML emails, unless you think most of your recipients won’t have Outlook 2010. You can either use the &bull character code or create a two column table, dropping the bullet graphic in the left hand column. Lengthy I know but the table approach is best supported.

Images

Images are easier to get right than text, but they can still be a pain. Here are few tips to get images to display well in HTML emails.

ALT text
Most email programs ask you to download images before they are displayed, and in place of the image the alt tag will be used. Therefore meaningful alt text can help encourage users to download and read emails.

Absolute paths
Upload you images to a server and reference them with the full “http://” path. While it’s possible to embed images as part of the email, I’d try and avoid this method as you’re forcing all your recipients to receive larger emails and I’ve rarely seen any HTML emails use this method. Plus there’s less chance of delivery due to SPAM filters.

Image alignment
If you need to align images within table cells or against text, use align=”left” rather than style=”float:left” as it’s more widely supported.

Image white-space bug
GMail and other webmail programs will insert annoying line spaces above and below images, which becomes more apparent when two images are next to each other. Use style=”display:block;” on the img tag to overcome this or style=”line-height:0px;” on the surrounding td tag.

Avoid background images
Be wary of the setting background images using the table background attribute or inline CSS, which is not supported in Outlook 2007 or Outlook 2010. This means that plain text cannot overlay a background image with universal support so emails should be designed with this in mind. You can opt for an adaptive design – one that still works with a plain background colour fall-back appearing instead, for email clients without the support for background images. The alternative if you have to have text over an image is to embed the text as part of the image. Not a solution I would usually recommend but in certain cases, this may be the best option.

Avoiding SPAM filters

My final set of tips revolves around how to best combat SPAM filters. Half the battle is creating well coded, HTML emails with plenty of plain text in the first place to maximising delivery but here are some of the more common factors in HTML email development that can trigger high SPAM ratings.

Does it sound like SPAM?
Avoid the overuse of spammy or promotional sounding words in any copy, especially the subject heading such as ‘offer’ or ‘free’.

High text to image ratio.
Purely image based HTML emails are going to get higher SPAM scores, especially if your recipients are new contacts

Avoid typos and using all caps
No one wants to see lots of typos or ugly, upper-case text which looks like they are being shouted at.

Clean code.
OK, so you’re HTML email code is more bloated than an equivalent web page but hand coded HTML emails, with little redundant code is usually the best way to go. Programs (such as Word) that can convert to HTML can create highly bloated and unnecessary code which will have much higher spam scores

Unsubscribe link
All emails should have a clear unsubscribe option. If your HTML email doesn’t, add one. If email filters aren’t checking for unsubscribe links, they probably should be.

16 Responses to “HTML Email Development Tips & Guide”

  1. Srinivas says:

    This tricks are very helpful to me……
    Thank you for sharing your valuable suggestions..

  2. Ashish Potdar says:

    Hello,
    Nice article on “HTML Email Development Tips for Cross Client Compatibility”.
    I am modifying my web application recently and found when ever my application is sending the email on gmail account, Gmail is adding his own tags in HTML formatted email and my is getting disturbed.
    tag is getting inserted.

    But this email format is working properly on other email address like hotmail,yahoo,rediffmail.

    Please suggest on this issue.

    Regards,
    Ashish Potdar

    • Hi Ashish,

      It sounds like your web application is adding some styles within the “head” tags, rather than in-line styles which Gmail will replace. If you can send some of the code the application produces, I can take a look. Also I think you were trying to add some HTML within your comment which was stripped out.

      Tom

  3. Ian Morris says:

    This is just what I was looking for. Thanks Tom. I searched for “Bullets in html email” and you came up second! :)

  4. Dennis B says:

    nicely done. i have also found the table formatting to be the only consistent method of aligning elements. The frustration around bullets in Outlook is how i found this post, and while disappointed, I’m glad I’m not the only one testing multiple methods to get those looking right.

  5. alex says:

    Thanks, the gmail whitespace thing was driving me nuts!

  6. Incredibly useful Tom.

    My HTML email is now working as intended using Thunderbird. In order to see what happened when it was replied to or forwarded I tested it on friends. In all but one case the replies lost the CSS text formatting (the tables layout/images were fine). Is there anything that can be done to avoid this. The email source is http://www.ipadcreate.com/cc-email/

    Thanks

    Graham

    • Hi Graham, glad you found the article useful!

      Although most email programs seem to retain HTML email structure and styling quite well when forwarding or replying, unfortunately it does seem that in some cases email programs (I’ve seen it in Outlook) will just decide to insert their own styles and in some cases this might be as a result of user settings.

      I haven’t done much testing on this myself but I don’t there’s anything that can be done (other than embedding all text as an image!) to force an email program to retain styles when forwarding. :S

      Tom

  7. Also I have noticed that the pointer hand that shows when you hover over a link is missing (although the link works) when the email is viewed in MacMail but appears in PC Thunderbird.

    • Hmm, an interesting one – is this when using regular a href links on text? When viewing the HTML email normally (not forwarding or replying) I would have thought all email programs should display the hand icon to indicate a link. Happy to take a look at your code :)

  8. Hi Tom

    I used Dreamweaver but I am not a coder. My links are in CSS I added cursor: auto to see if it made a difference, it didn’t.

    a:link {
    color: #B01021;
    }
    a:visited {
    color: #B01021;
    }
    a:hover {
    color: #929661;
    cursor: auto;
    }
    a:active {
    color: #B01021;
    }

    This is the web page I am using http://www.ipadcreate.com/cc-email/

    Thanks for taking an interest

    Best

    Graham

    • Hi Graham,

      Ah – CSS in the head tag is often ignored and you want to use cursor:pointer to get the hand – cursor:auto might actually be overriding the hand cursor. You might want to try to adding the style to the link itself e.g. a href=”blah” style=”cursor:pointer” – if the style is being overwritten somewhere.

      Hope that helps :)

      Tom

  9. Scott says:

    I use htmlforemail.com for all the coding for my email marketing campaigns but this is very good. I should trying coding myself:)
    Thank you for sharing your valuable suggestions..

  10. Phil says:

    Great article, lots of great information, but… I was struggling with images showing up in my gmail and hotmail accounts. I use them to test my html emails. I tried the “display:block” and it did not work. After some trial and error, I found that if I surrounded my image tag/absolute paths with tags, gmail and hotmail would finally reveal my images. I also found that the ‘align=”right” ‘ or left didn’t work either. It prevented my images from showing. If I removed it entirely from the tag, my images would magically appear in gmail and hotmail. To position them, I still used “float” even though the email clients seemed to disregard it. The browser I am using is Google Chrome, and I was doing a “Mail Merge” from Outlook 2007 (which converts html emails to Word files) for sending the emails to gmail and hotmail. That’s not to say that your methods don’t work at all, obviously they do, but in my situation, this is what worked. BTW, I am using Notepad++ for creating the html emails.

    • Tom says:

      Hi Phil, thanks for sharing your methods. Yeah, the display:block tip helps get around the white space issue with two separate adjacent images in HTML emails. I almost always use table cells as a way to position images if possible – I can’t say how effective the Outlook to Word approach is for sending emails (I suspect it might meddle with the code somehow) but once I’ve created the HTML email, I often use a 3rd party service such as MailChimp or YMLP to send the HTML bulk email. I think YMLP might even be free if sending to small number of recipients

Leave a Reply

*