CSS in HTML Email

CSS (Cascading Style Sheets) is nice for websites, but don’t relay too much in it with HTML email. For instance, you shouldn’t expect DIVs to work. And definitely avoid CSS positioning – it won’t work. Use old-fashioned <TABLES> tags for your layouts in HTML email, and only use CSS for simple font formatting and colors. Always design your email so that it looks decently if someone removes your CSS. Before you send your HTML email, delete the CSS and see how it displays.

CSS is especially a touchy situation if you’re using a WYSIWYG to design your HTML email, because WYSIWYGs insert all kinds of crazy CSS and DIVs by default. It’s one of the drawbacks of WYSIWYGs for HTML email. It may help you get things coded, but you still have to understand HTML enough to go back and remove some of the code, so things won’t break in email applications.

Stylesheets that Stick

When you’re coding an HTML email with CSS, make sure that you don’t use linked CSS files (.css files attached using link or @import). These stylesheets are most widely ignored by email clients.

CSS style declarations in the head of an HTML document (using style tags) are ignored by some email clients, such as Gmail, so they should be avoided for styles that are key to the email design.

The most reliable way to include CSS in an HTML email is to use inline styles. They aren’t pretty, but few email clients ignore them. These styles are defined within the HTML tags in the body of the document, like this: <p style="color:green;font-family:sans-serif;">green and arial text</p>.

Using span tags to apply inline styles also works well.

Layout Techniques

Most people suggest using table, tr, and td tags for page layout within an HTML email. Tables are the most stable option, especially if you’re creating email messages that require a more complicated multi-column layout. Gmail simply removes div tags, and coverage in other clients like Hotmail is spotty. Also, floating div tags don’t work in several email clients, so any floating elements can be placed in a table (using <table align="left">, for example).

Using a div tag for a layout or background color is a better option when you’re working with a single-column layout. Applying styles to div tags using inline styles versus a style tag will help keep that style in place when the email ships out to the masses.

On the bright side, you can scale back on div tags if they’re causing problems, and use the almost universally supported table, tr, and td tags for anything you can’t accomplish reliably with a div.

Formatting Text

The best way to make sure your text formatting sticks is to use inline styles, but applying an inline style to every bit of text is tedious and may add too much extra weight to the HTML. If you aren’t especially picky about details like the exact pixel size of your text, whether your "black" text shows up dark gray, and how your links are underlined, you’ll probably be happier applying text formatting with a style tag rather than inline.

One place where inline styles may make a real difference is in the headings and special notes within your email. When you want to ensure that a certain notice is always red, or that headings are the same shade of orange as your logo, you should use inline styles for that formatting.

Some email clients are notorious for changing text in strange ways that can only be overridden with inline styles. Hotmail, for example, always displays links in small blue Verdana, regardless of the appearance of the rest of the email. If this is a problem for you, you should use inline styles on each link tag to override it.

General "Do’s" and "Don’t’s" for HTML Emails with CSS

Do …

Read more on CSS in HTML Email…

Flash (JavaScript, Movies, and Other Stuff) in HTML Email

You can send the HTML emails with Flash files in them, but the majority of your recipients won’t be able to view them. This is because only Microsoft Outlook and Apple Mail use the operating system’s built-in browsers to render their email. Other email applications use their own, proprietary ways of rendering HTML. Plus, most people have anti-virus and anti-spam applications that block the code used to embed Flash files.

Read more on Flash (JavaScript, Movies, and Other Stuff) in HTML Email…

HTML Email in Web-Based Email Applications

Many of your recipients will be viewing your newsletter in their web browsers like Yahoo!Mail, Hotmail, or Gmail. There are certain things you need to know about web-based email applications:

  • They strip out the <HTML>, <HEAD>, and <BODY> tags in order to keep your code from interfering with their web pages. That means that any background colors you specify in your <BODY> tag will be lost. To avoid this, insert your entire email inside a larger, 100% wide table, and set a background color to that table.

Read more on HTML Email in Web-Based Email Applications…

Tailoring “From” and “Subject” Lines for Email Clients

So you got a great email message design, wrote a perfect Subject line, added your company name to the From field and you think you’re ready to send the email out. Wait a minute. You work may not be over yet. You probably will need to spend some time for optimizing your From and Subject lines. What does it mean and why is optimizing the From and Subject lines so important?

You know different email clients render the From and Subject lines in different ways. This is one of the challenges of distributing email newsletters.

Some email clients limit the quantity of characters if the From and/or Subject lines. So, if your Subject is too long, it will be cut off and may be unreadable for the recipient. In some email programs the From and Subject lines are interrelated – the longer the From field, the shorter the Subject line is allowed. The From field can be displayed either as Name + Email Address, or Name, or Email Address in different email programs.

It’s good if you know what email clients your recipients use to view your emails. You can then tailor your "From" and especially "Subject" lines to display properly for all the recipients. If you don’t have the information about your recipients’ email programs, try to optimize your message at least for the most common email clients listed in the table below.

Read more on Tailoring “From” and “Subject” Lines for Email Clients…

How to Avoid Mistakes in the Future

In order not to be in an awkward situation that may affect your relationship with the subscribers or customers, just follow these rules before you send the message to the list:

Read more on How to Avoid Mistakes in the Future…