How to Code HTML Email NewslettersBy Tim SlavinJune 16th 2006 Reader Rating: 8.9 Note: This article has been updated by the author and republished, replacing the original article from 2004. The HTML [1] email newsletter is a very successful communications medium for both publishers and readers. Publishers can track rates for email opens, forwards, and clickthroughs, and thereby can measure reader interest in products and topics; readers are presented with information that's laid out like a web page, in a way that's more visually appealing, and much easier to scan and navigate, than plain text email. | |||
Yet coding HTML email can be a mix of misery and pain for programmers. The biggest pain is that so many different software tools are available for reading email, from desktop software such as Eudora, Outlook, AOL, Thunderbird, and Lotus Notes, to web-based email services such as Yahoo!, Hotmail, and Google Mail. If you thought it was difficult to ensure the cross-browser compatibility of your web sites, be aware that this is a whole new game -- each of these email software tools can display the same email in vastly different ways. And even when these tools do display an HTML email properly, accounting for variances in, for example, the widths at which readers size their windows when reading emails makes things even trickier. This article describes the results of my own hands-on experience creating HTML email newsletters for clients, as well as bits of technical information from the Internet. This is actually a revision of an article that was written and published on sitepoint.com in 2004, and includes new, up-to-date material that will help you ensure that your HTML email newsletters meet the requirements of today's email clients. Step 1: Use HTML Tables for LayoutThat's right: tables are back, big time! Web standards may have become the norm for coding pages for display in web browsers, but this isn't the Web, baby. Mail clients are light years behind the eight-ball in terms of CSS [2] support, which means that we must resort to using tables for layout if we really want our newsletters to display consistently for every reader (see the reading list at the end of this article for some excellent resources on CSS support in mail clients). So put your standards-compliant best practices and lean markup skills aside: we're about to get our hands dirty! The first step in creating an HTML email is to decide what kind of layout you want to use. For newsletters, single column and two-column layouts work best, because they control the natural chaos that results when a large amount of content is pushed into such a small space as an email. A single-column layout typically consists of:
Two-column emails also use a header and footer. Like a two-column web page, they typically use a narrow, side column to house features and links to more information, while the wider column holds the body content of the email. Promotional emails follow similar rules but contain much less in the way of content and links. They often include one or two messages, and sometimes make use of one big image with small explanatory text and some links below the image. All of these email layout possibilities can be created easily, using HTML tables to divide up the space into rows and columns. In fact, using HTML tables is the only way to achieve a layout that will render consistently across different mail clients. This is the approach that I use to create HTML emails:
While this approach might offend purists who prefer to code using the latest standards, it is the only approach that's viable at this point. But the fact that we're using tables for layout doesn't mean we need to resort to old-school methods entirely. For example, no matter how poorly Lotus Notes displays HTML email, you should never have to resort to using the Step 2: Add CSS StylesDid I say CSS support was poor in mail clients? Well, it is. But you can (and should) still utilize CSS for the styles in your email once your nested table layout is in place. There are just a few things to watch out for. Here are the steps that I use. First, use inline styles to store all of your style information, as shown here:
This includes For your container table -- the one that houses the header, content, and footer tables -- set the table width to 98%. It turns out that Yahoo! mail needs that 1% cushion on either side in order to display the email properly. If side gutters are critical to your email's design, set the width to 95% or even 90% to avoid potential problems. Of course, the tables inside the container table should be set to 100%. Put general font style information in the table One way to make up for this redundancy is to use CSS shorthand wherever possible (the TRBL acronym will help here: Top, Right, Bottom, Left). For example, consider the following markup:
Instead of the above code, use this format (remembering the TRBL rule):
Use While Note that some email delivery services will unpack style definitions to make them more explicit and, therefore, more readable by all email software. For example, the CSS shorthand Step 3: Adopt Best PracticesKnowing that you've created valid HTML email using the guidelines I've suggested is only part of the solution -- there are several best practices that you should follow to ensure that your email is well received. The next step is to test your HTML email in a variety of email clients. Often this will identify problems that require workarounds. The first test tools to use are the Firefox [3] and Internet Explorer web browsers. If the email displays well or perfectly in both browsers, there's a good chance that testing the email in Outlook, Yahoo!, Google Mail, and other services will reveal only minor problems. Once the email appears fine in those two web browsers, use an email delivery service to send the email to a range of test email accounts. Ideally, this should include accounts with the Yahoo!, Hotmail, and Google Mail services. Here are the most common code tweaks that I've found necessary during this test phase:
In addition, the following best practices are recommended:
As part of testing an email, also include a test for potential "spamminess". SpamCheck [5] is a useful service that highlights issues that might cause an email to trigger spam filters. While it comes bundled as a tool called Site Build It, that is available for purchase, the online version of SpamCheck is a free service, and no purchase is necessary to make use of it. Once the HTML email has been tweaked so that it displays well in your test email accounts, the next step is to go through a checklist. For example, verify the following:
If it's important for you to know absolutely everything that could go wrong with the way your HTML email is rendered, try a service like Browsercam.com [6]. For a small hourly fee, you can post the email as a web page on a server, then point Browsercam at the page. Browsercam will take snapshots that show how the email appears on a wide range of browsers and operating systems. While the snapshots don't show how email software will display an email, many email clients use web browser components to display HTML email, so Browsercam is a good way to increase the chances that you will spot any rendering issues. Step 4: Code for Google Mail and Lotus NotesIt seems obvious that a relatively new service like Google Mail, which uses a web browser to display email, would display HTML email perfectly and support the latest web standards. Unfortunately, this is not the case. Because Google cannot control the contents of the emails it displays, the service providers have had to take steps to ensure that their application displays properly regardless of the quality of the HTML or CSS in which emails are written. As a result, Google Mail is a new web mail service that acts like an artifact of the early 1990s, when web standards were primitive. It takes some work, but it is possible to crack open a Google Mail page and see just how convoluted the services approach to rendering HTML email actually is. For one thing, Google Mail deletes the CSS styles contained between any style tags, no matter where they appear in the email. And fonts displayed within HTML tables -- the only alternative to using styles -- have the odd habit of appearing larger than intended, no matter how the HTML email is structured. Here are some techniques that appear to work well in Google Mail and older email software:
Besides Google Mail, there's another, less obvious hazard a programmer faces when creating HTML email: Lotus Notes. Many large corporations continue to support and upgrade their Notes installations (as of 2004, IBM reported that 95 million people used Notes). Unfortunately, it's impossible to tell which companies use Notes. The best approach is to follow the guidelines described in this article -- the more primitive the code, the more likely it will work well, if not perfectly, with Notes. That said, it's quite possible that Notes will introduce to your HTML email quirks that are almost beyond belief. For example, the software can convert images to their proprietary formats, or simply ignore flawless basic HTML in one email, but display other HTML fine in another email. A trial version of Lotus Notes is available for download if you need to test your mail in Notes -- see the resource list at the end of the article. Here are a few tips that will help you convince Notes to display your HTML email properly:
SummaryMany people who receive email prefer HTML over text for a number of reasons. For programmers, though, the task of creating an HTML email that will display consistently appears both simple and horribly complex. This article has described many of the issues and strategies for creating markup that will work across email software. What's the best idea to take away from this article? If there's a choice to be made between a simple email design and a more complex solution, simplicity is always the safest bet. Further Reading These resources offer valubale information that will help you if you want to learn more about coding HTML email. MailChimp Weblog [7] HTML Email Tips for Web Designers [8] CSS Support in HTML Emails of Hotmail, Yahoo! Mail, and Gmail [11] by Xavier Frenette A Guide to CSS Support in Email [12] \">The "Secrets of HTML Email" Series [13] Lotus Notes Trial Software [14] Browsercam [15] SpamCheck [16] CSS-Discuss: HTML Email and Using Style [17] DadaMail Software [18] CSS and Email, Kissing in a Tree [19] How HTML Code Affects E-Mail Deliverability [21] | |||
TopicsBefore You CodeDesign and Layout
Client Side CodingServer Side Coding
Site StrategySite MarketingSell Your Services |
sábado, enero 06, 2007
Codificación de documentos para correo HTML
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario