Questions tagged [html-email]

HTML used to format emails (message content, not email addesses)

Although the HTML used to format emails is the same as that used to create web pages, it has a different set of problems and best practices.

Code Validation

Since most email clients don’t follow web standards and there are no email-specific standards in place, properly coded HTML emails will not pass HTML validating because, if coded properly, nearly all of the code within an HTML email is likely to be comprised of depreciated elements.

Client Code Compatibility

In working with HTML emails, much of the functionality possible in typical web development is not possible in email. Good practice, is to restrict code usage to that which is XHTML1.0 compliant. Recent upgrades to many platforms have allowed for some loosening of that restriction and it is now common for people to use the HTML4.0 compliance standard.

DOCTYPE

The recommended doctype for HTML email is XHTML 1.0 Strict. The reason for this is because, regardless of any alternative doctype definition, Gmail will impose XHTML 1.0 Strict regardless and of the two clients which impose their own doctype, Gmail has the largest percentage of users so it is only logical to confirm to the standard that will be imposed whether you like it or not.


Below is a list of Email Clients and Their Treatment of !DOCTYPE as well as expected results.

STRIP or IGNORE your DOCTYPE entirely:

  • AOL
  • Android Gmail Application
  • Lotus Notes 6.5, 7, 8 and 8.5
  • Outlook 2007 and 2010
  • Thunderbird 2 and 3
  • Yahoo

    Results:

    • Box model padding becomes an issue when viewing your email in IE vs Firefox
    • In IE 8, CSS padding on TABLEs are reset to “0″ – for example:
    • Center tags with a set width will no longer be centered in all browsers except IE. For example:
    • In IE, the minimum height on any EMPTY block element is 19px This is particularly important when using spacer divs.
    • In all browsers except for IE 6 and 7, paragraph elements have a default top and bottom margin of “0″ whereas it would otherwise use a default top and bottom margin of 16px.
    • In IE 8, you might see an exaggerated left margin on OLs and ULs, you will need to define the margins with inline CSS to correct this.
    • Some special characters are not supported

ACCEPT your DOCTYPE

  • Android Mail Client
  • Entourage 04 and 08
  • iPad and iPad Gmail
  • iPhone and iPhone Gmail (iOS3 & iOS4)
  • Kindle Fire
  • Live Mail
  • Outlook 2003
  • Outlook Express
  • Thunderbird 6
  • Windows Mail

Impose Their Own Standards

  • XHTML 1.0 Strict – Gmail & Hotmail

    Results:

    • Line height for small fonts may become more prevalent in all browsers except for IE. This is only an issue when using inline elements, use paragraph elements or TDs for formatting your small fonts.
    • You might see a small space below each of your images. A common fix is to useinside your image tag.
    • Some special characters are not supported
    • There may be a difference in the way your text links appear (colored underlines)
  • Yahoo Classic – HTML 4.01 Transitional

Mailchimp KB

SlideShare

SixRevisions guideline

5038 questions
348
votes
12 answers

Send HTML emails with Python

How to send HTML content in email using Python? I can send simple texts.
ha22109
  • 8,036
  • 13
  • 44
  • 48
330
votes
2 answers

What's a 3D doing in this HTML?

I'm trying to duplicate a mailer I got into my gmail by taking a look at its code. I see a lot of this in multiple source viewers:
Nic
  • 13,287
  • 7
  • 40
  • 42
218
votes
7 answers

Best practices for styling HTML emails

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…
Joe Mornin
  • 8,766
  • 18
  • 57
  • 82
146
votes
5 answers

Is there an equivalent of CSS max-width that works in HTML emails?

I'm trying to create an HTML email that will display properly in all widely used email clients. I'm wrapping the whole email in a table, and I'd like it to have a width that is up to 98% of the available width, but no greater than 800 pixels. Like…
Tim Goodman
  • 23,308
  • 7
  • 64
  • 83
133
votes
6 answers

When creating HTML emails, should we use html, head, body tags?

In my email views, I usually just do something like...
Name
Value
Should I be doing it like this?
Name
Value
In…
alex
  • 479,566
  • 201
  • 878
  • 984
113
votes
8 answers

What's the best way to center your HTML email content in the browser window (or email client preview pane)?

I normally use CSS rules for margin:0 auto along with a 960 container for my standard browser based content, but I'm new to HTML email creation and I've got the following design that I'd like to now center in the browser window without standard…
Joel Glovier
  • 7,469
  • 9
  • 51
  • 86
112
votes
8 answers

Styling HTML email for Gmail

I'm generating a html email that uses an internal stylesheet, i.e.

Email content here When viewed…

Dónal
  • 185,044
  • 174
  • 569
  • 824
111
votes
4 answers

What is Data URI support like in major email client software?

Data URIs are a standard way to embed images and other binary data in HTML, and browser support is well documented on the web. (IE8 was the first version of IE to support Data URI, with a max 32 KB size per URI; other major browsers have supported…
joelhardi
  • 11,039
  • 3
  • 32
  • 38
101
votes
2 answers

Send a base64 image in HTML email

Using a rich-text editor, our users can drag and drop a saved image from their desktop to the editor. The image appears and displays properly in the web page after they submit. Since the image is not uploaded anywhere, the editor saves the image as…
Vael Victus
  • 3,966
  • 7
  • 34
  • 55
95
votes
10 answers

Has anyone gotten HTML emails working with Twitter Bootstrap?

I'm using the premailer-rails3 gem which pulls styles inline for html emails, and I'm trying to get it working with Twitter bootstrap. https://github.com/fphilipe/premailer-rails3 It looks like some styles come in correctly, but not all of them. …
Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
93
votes
3 answers

Best Practices & Considerations when writing HTML Emails

I've been developing websites for over a decade now, but quickly found that many of my habits in developing for the web are useless when developing for email clients. This has caused me an enormous amount of frustration, so I thought I would ask a…
Sampson
  • 265,109
  • 74
  • 539
  • 565
88
votes
20 answers

HTML image not showing in Gmail

I'm sending an e-mail newsletter in HTML. Inside the HTML I have something like When I open the newsletter with Thunderbird or Outlook, the image is being…
Rita
  • 1,233
  • 2
  • 14
  • 23
82
votes
4 answers

HTML email: tables or divs?

Does the HTML/CSS for an html email newsletter need to be in table format, or can I use DIVs with equal assurance it will display well cross email-client? I've downloaded a number of templates to see how they're done, upon which to base my own, and…
HandiworkNYC.com
  • 10,914
  • 25
  • 92
  • 154
75
votes
2 answers

How can I embed SVG into HTML in an email, so that it's visible in most/all email browsers?

I want to generate graphs in SVG, and email an HTML page with those graphs embedded in it (not stored on a server and shown with linked images). I've tried directly embedding the SVG, using the Object element, and serializing and URI encoding the…
ztforster
  • 1,369
  • 2
  • 10
  • 20
70
votes
11 answers

Remove spacing between table cells and rows

I'm designing an HTML email template, which forces me to use tables. In the code below, I'm having trouble (1) removing the spacing below the placeholder image and (2) removing the space between the image and the caption. Here's a screenshot of how…
Joe Mornin
  • 8,766
  • 18
  • 57
  • 82
1
2 3
99 100