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
21
votes
3 answers

Sending HTML email in django

In my project I've added a newsletter feed. But when trying to send emails with this function : def send(request): template_html = 'static/newsletter.html' template_text = 'static/newsletter.txt' newsletters =…
crivateos
  • 925
  • 3
  • 10
  • 19
21
votes
8 answers

How do I send email with JavaScript without opening the mail client?

I'm writing a HTML page with a registration button that should just silently send an email without opening the local mail client. Here is my HTML:
j3d
  • 9,492
  • 22
  • 88
  • 172
21
votes
3 answers

Break long words in html email in outlook 2010

I'm taking end user input and inserting it into an HTML email. But if the end user enters a long URL or really long word, it breaks my HTML layout in Outlook 2010 by extending the column or div beyond the width specified. In Chrome, Firefox, IE7+,…
Hoppe
  • 6,508
  • 17
  • 60
  • 114
20
votes
10 answers

Outlook 2013 Cutting off top of image?

I am setting up an email template and the top of a few images were being cut off. This is my code for the images I have the line height on the td so that the white space…
jakecraige
  • 2,707
  • 4
  • 21
  • 25
20
votes
5 answers

how to use customs fonts in emails or email templates

how to use customs fonts in emails or email templates Why we cant use custom fonts in emails, why @font-face style is not supported by most of the mail providers
Akhilraj N S
  • 9,049
  • 5
  • 36
  • 42
19
votes
1 answer

Is it possible to modify "from" field in mailto link?

I'm trying to get a mailto link that would open a new outlook email window with a modified from field (i.e. to use a secondary account as it were). Is that possible?
Ilia Draznin
  • 1,026
  • 2
  • 12
  • 24
19
votes
4 answers

Exclamation Point in HTML Email

I am having a hard time formatting a table in an HTML email. There seems to always be one cell that doesn't have the background color or weird white spaces. Here is the code (in php) - $subject.="

Haru
  • 1,361
  • 2
  • 15
  • 40
19
votes
2 answers

How do I indent the first line of a paragraph using HTML inline styling?

I'm creating an HTML email and I do not want to use CSS styling in the head (for cross platform compatibility reasons). I need to set an indention for the first line of the paragraph using inline styling only. How would I do that?
jarrodwhitley
  • 826
  • 10
  • 29
19
votes
2 answers

Is there a way to use Google Web Fonts in an HTML email?

An HTML email must (should) have its CSS inlined in order to have the expected design in most of the email clients. Is there a way to link a Google Web Font to or embed in such an email but still maintain a broad acceptance (appropriate rendering)…
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
19
votes
2 answers

Is it safe to use protocol relative URL in email?

There are existing discussion [1] on the use of protocol relative URL in HTML, but how about email? Will email client, or service providers like Gmail strip or modify protocol relative URL when they are used in HTML email? [1] Can I change all my…
Howard
  • 19,215
  • 35
  • 112
  • 184
19
votes
3 answers

Making only the link destination editable in MailChimp

Is there a way to only allow a user to edit a link's destination, and not the link itself, using MailChimp's template language? There doesn't seem to be anything about this specific situation in their documentation. For example:
Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
19
votes
2 answers

Make elements overlap in cross-client HTML emails?

In normal HTML for browsers, making elements overlap is easy. But in the dark world of HTML email, where the motto is "code like it's 1996" because Outlook uses the rendering engine from MS Word and Gmail removes almost everything, every method for…
user56reinstatemonica8
  • 32,576
  • 21
  • 101
  • 125
19
votes
4 answers

center align email in outlook.com

I have created a very simple html email. http://staging.xhtml-lab.com/mailtest/ It's working fine in all email clients, except in hotmail.com/outlook.com in hotmail email is left aligned, it should remain center aligned. I have added following code…
Alok Jain
  • 3,379
  • 3
  • 23
  • 42
19
votes
5 answers

Font Color in HTML Email - Gmail

I know that I have to use inline CSS to style anything in an HTML email, but I am noticing an odd override that is occuring in gmail. I am trying to change the color of the text in a table row:
css
Kevin_TA
  • 4,575
  • 13
  • 48
  • 77
18
votes
1 answer

Can an HTML email body reference a file sent as an attachment (in the same email)?

Can an HTML email use an image attachment as the source for tag? Let's say I am sending an email with per-email specific images - and they are sent as an attachment to the email - can the HTML body within the email use the those images? My guess…
Goro
  • 9,919
  • 22
  • 74
  • 108