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
69
votes
12 answers

How to get rid of "Show trimmed content" in GMail HTML emails?

I send a lot of HTML emails. The problem with GMail is, if there are more than one emails with the same subject, it hides some similar content and shows a "..." to show the "trimmed content". This screws up with my formatting. If changing the…
Munim
  • 6,310
  • 2
  • 35
  • 44
58
votes
6 answers

HTML formatted email not showing up at all in Gmail but is in other mail clients

I'm currently sending html formatted emails from PHP's mail() function and checking them simply to make sure they are showing up as HTML (formatting aside, I'm well aware that the formatting will vary (probably drastically) from client to client).…
joshholat
  • 3,371
  • 9
  • 39
  • 48
58
votes
9 answers

Why is Gmail blocking CSS in emails?

I used CSS in my email and sent it out. When I received the email in Gmail, all the CSS was disabled; however, when I retrieved the email in thunderbird or outlook, everything is OK. How would I fix this?
MemoryLeak
  • 7,322
  • 23
  • 90
  • 133
53
votes
1 answer

GMail displays plain text email instead HTML

My Rails 3 application sends out emails in both plain text and HTML formats. I have tested it locally using RoundCube and Squirrel Mail clients and they both display HTML version with images, links, etc. GMail on the other hand chooses plain text…
Vincent
  • 16,086
  • 18
  • 67
  • 73
52
votes
3 answers

Base64 encoded image is not showing in gmail

I have an embedded HTML email in which I'm using a base64 encoded image. Image doesn't show in gmail when accessing via chrome. But it works fine when accessing same mail via mail client(Mail application on Mac). I have set headers correctly. Any…
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
47
votes
4 answers

HTML Emails: fallback for mso conditional?

UPDATE 2023: This question was originally asked in 2013 - the landscape and supported technologies have changed greatly in that time. The accepted answer is functional and effective for legacy clients, but Frank Hagenson's answer is most likely to…
CodeMoose
  • 2,964
  • 4
  • 31
  • 56
46
votes
12 answers

Gmail is ignoring "display:none"

I have a query that Gmail is ignoring display:none. What to do? In email HTML for hiding a row or div.
Sagar
  • 1,387
  • 2
  • 13
  • 22
46
votes
4 answers

Is there no way to embed a Google Map into an HTML email?

I have done a good amount of research and have found several "solutions" such as the static maps API and simply sending a link to a Gmap. However is there really no way to actually send someone a Google Map?
Ben Racicot
  • 5,332
  • 12
  • 66
  • 130
45
votes
10 answers

Outlook 2010 overriding font-family from Arial to Times New Roman

I'm programmatically sending HTML-formatted email, and setting the font as Arial throughout (font-family: Arial;). When the messages arrive in Outlook 2010, text in table elements is in Times New Roman. Text in div elements is fine in Arial. If I…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
41
votes
8 answers

HTML email in Gmail - CSS style attribute removed

I'm working on an HTML email and I am using MailChimp's Responsive Email Templates in combination with their CSS inliner tool. For the most part, the email looks great across the myriad of email clients, but in Gmail things are horribly…
Matty B
  • 1,008
  • 2
  • 13
  • 25
40
votes
8 answers

HTML Email iOS format-detection

I just found that there is a meta tag for removing the phone number as a link in HTML on iOS. Does this work with HTML emails? But is there one for address and date as well? I have always been…
Travis
  • 2,185
  • 7
  • 27
  • 42
37
votes
6 answers

How to send HTML email

i found a way to send plain text email using intent: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new …
Denis Palnitsky
  • 18,267
  • 14
  • 46
  • 55
37
votes
3 answers

Is there any sense in using the tag in HTML e-mail?</a></h3> <div class="excerpt">When sending an HTML e-mail, is there any sense in using the <title> tag? In the PHP Manual, for instance, they use such a tag in their main sample code. However, I see no reason why an e-mail client would use this title and not the Subject from the…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/email" class="post-tag grid--cell" title="show questions tagged 'email'" rel="tag">email</a> <a href="../../questions/tagged/html-email" class="post-tag grid--cell" title="show questions tagged 'html-email'" rel="tag">html-email</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card__deleted"> <time class="s-user-card--time" datetime="asked Sep 02 '12 at 16:35">asked Sep 02 '12 at 16:35</time> <div class="s-avatar s-avatar__32 s-user-card--avatar"> </div> <div class="s-user-card--info">user1162541</div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-8998378"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>36</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>26</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/8998378/how-do-i-remove-link-underlining-in-my-html-email" class="question-hyperlink">How do I remove link underlining in my HTML email?</a></h3> <div class="excerpt"><td width="110" align="center" valign="top" style="color:#000000;"> <a href="https://example.com" target="_blank" style="color:#000000; text-decoration:none;">BOOK NOW </a> </td> I used this code to make a link in my HTML email. In…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/html" class="post-tag grid--cell" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/css" class="post-tag grid--cell" title="show questions tagged 'css'" rel="tag">css</a> <a href="../../questions/tagged/html-email" class="post-tag grid--cell" title="show questions tagged 'html-email'" rel="tag">html-email</a> <a href="../../questions/tagged/newsletter" class="post-tag grid--cell" title="show questions tagged 'newsletter'" rel="tag">newsletter</a> <a href="../../questions/tagged/email-client" class="post-tag grid--cell" title="show questions tagged 'email-client'" rel="tag">email-client</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 25 '12 at 05:44">asked Jan 25 '12 at 05:44</time> <a href="../../users/1111071/pubudumj" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1111071.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="pubudumj" /> </a> <div class="s-user-card--info"> <a href="../../users/1111071/pubudumj" class="s-user-card--link">pubudumj</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">361</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="3 silver badge">3</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badge">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-8012799"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>36</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/8012799/do-we-still-need-to-use-font-tags-in-html-emails" class="question-hyperlink">Do we still need to use <font> tags in HTML emails?</a></h3> <div class="excerpt">I'm taking over from someone who builds our HTML emails and the templates are filled with font tags. Is this really necessary? I know CSS support isn't great in emails, but if I set an inline style for text on the container <td> like this... <td…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/html" class="post-tag grid--cell" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/email" class="post-tag grid--cell" title="show questions tagged 'email'" rel="tag">email</a> <a href="../../questions/tagged/html-email" class="post-tag grid--cell" title="show questions tagged 'html-email'" rel="tag">html-email</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 04 '11 at 16:43">asked Nov 04 '11 at 16:43</time> <a href="../../users/467859/punkrockbuddyholly" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/467859.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="punkrockbuddyholly" /> </a> <div class="s-user-card--info"> <a href="../../users/467859/punkrockbuddyholly" class="s-user-card--link">punkrockbuddyholly</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">9,675</li> <li class="s-award-bling s-award-bling__gold" title="7 gold badges">7</li> <li class="s-award-bling s-award-bling__silver" title="36 silver badges">36</li> <li class="s-award-bling s-award-bling__bronze" title="69 bronze badges">69</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=1" rel="prev" title="Go to page 1">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=1" rel="" title="Go to page 1">1</a> <div class="s-pagination--item is-selected">2</div> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=99" rel="" title="Go to page 99">99</a> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=100" rel="" title="Go to page 100">100</a> <a class="s-pagination--item" href="../../questions/tagged/html-email_page=3" rel="next" title="Go to page 3"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>