Developing HTML Emails for Gmail: 12 Things you MUST know

Mar 8, 2017 Update:
This article has been updated to reflect the big Gmail update that included support for responsive email.
  1. Gmail has several email clients.
  2. Gmail app for non-google accounts (GANGA) does not support background images.
  3. Gmail clips your message at 102K.
  4. Gmail only supports in the
  5. Gmail removes your entire block if it encounters an error.
  6. Gmail displays preheader text in the subject-line.
  7. Gmail does not support attribute selectors and most pseudo-classes.
  8. Gmail displays an image download icon over large unlinked images.
  9. Gmail does not allow negative CSS margin values.
  10. Gmail automatically converts phone numbers and URLs to links.
  11. Gmail uses the HTML5 DOCTYPE.
  12. Gmail’s DOCTYPE can create extra space under images.

1. Gmail has several email clients.

Although Gmail is most often identified with their Webmail and mobile apps, Gmail has many different versions and incarnation. This includes Gmail’s Inbox client, G Suite for business as well as a particularly problematic version of their Android client thats configured for POP/Imap access (see #2).

Remi Parmentier has published an article on the different Gmail clients.

2. Gmail app for non-google accounts (GANGA) does not support background images.

The Gmail Android app that comes pre-installed with most new Android phones contains a feature to access non-Google accounts using POP and IMAP. Emails accessed through this setup lack the embedded style () support as well as the support for background images.

3. Gmail clips your message at 102K.

If your email exceeds 102K, Gmail will display the first 102K along with a message that reads:

[Message clipped]  View entire message

When the user clicks to view the entire message, your email will be displayed in a new window.

If you are close to 102K, you might save a few bytes by removing any unnecessary spaces, carriage returns or comments. 

We recommend that you avoid embedded images and documents when sending HTML emails.

4. Gmail only supports in the .

Gmail now supports embedded styles (). However embedded styles are only supported in the head of your HTML document. The Gmail Android app does not support at all when rendering emails retrieved through non Google accounts (GANGA).

5. Gmail removes your entire block if it encounters an error.

Gmail is very finicky when it comes to parsing embedded styles. If it encounters even one error, it throws away the entire block. 

Gmail does not like an ‘@’ declaration within an ‘@’ declaration.(see details here). One way to deal with this is to use multiple style blocks and put the styles that are Gmail safe in the top block.

@media only screen and (max-width:320px) {
@viewport { width:320px; }
}

Gmail eliminates your style block if it exceeds 8192 characters.

If your style block exceeds 8192 characters, split it into two parts as Gmail will only remove the latter block that exceeds the treshold (the 8192 character limits is a sum of all your style blocks).

6. Gmail displays preheader text in the subject-line.

Like many modern clients, parts of the text in your body – the preheader – is automatically shown after the subject without the recipient having to open the email message. This text can be a visible part of your email body or it can be specially crafted to only display before the email is opened. This technique is covered in this article.

7. Gmail does not support attribute selectors and most pseudo-classes.

Attribute selectors like the one below allow for a more flexible selection of elements in CSS. Although they are supported in modern email clients such as iOS and Apple Mail, they are not supported by Gmail.

div[class="content"]{ color: red }

Gmail also does not support pseudo-classes like :checked and :active and only supports :hover in their Webmail email client. Therefore interactive email support in Gmail is very limited or non-existent.

8. Gmail displays an image download icon over large unlinked images.

Gmail will overlay an icon that lets recipients download images that are not wrapped with a URL. This can be frustrating to designers who would rather Gmail not mess when their email designs.

The simplest solution is to ensure that your images larger than 300×150 are wrapped with a link, however this article goes into several other options as well.

9. Gmail does not allow negative CSS margin values.

Most webmail clients such as Outlook.com and Yahoo! Mail do not allow negative margin values and Gmail is no exception.

10. Gmail automatically converts phone numbers and URLs to links.

Both the desktop and mobile version(s) of Gmail now insert an anchor link around phone numbers. In the desktop version, the link opens Google’s new voice/chat console which is displayed along the right column of the Gmail interface.

To block this, use an HTML entity in your phone number that Gmail does not recognize such as “­”

­212­-389­-3934 

In the above example we inserted this entity before each dash.

Click here for more examples and fixes.

If you have a URL or email address listed without a link, Gmail will add it for you.  For example name@test.com within this paragraph will get converted to:

<a href=“mailto:name@test.com”name@test.com</a

Here are two possible fixes:

1.) Insert an HTML entity that Gmail does not recognize, like:

&#173;­ 

So change name@test.com to:

name@test­&#173;.com 

Change www.mydomain.com to:

www.mydomain­&#173;.com 

Change http://www.mydomain.com to:

http:&#173;­//www.mydomain­­.com 

2.) Insert an anchor around the URL or email address and format it like the rest of your text.  For example:

<a href=’#’ style=“color:#000; text-decoration:none”test@test.com</a

11. Gmail uses the HTML5 DOCTYPE.

Regardless of the DOCTYPE specified in your email, the email will be rendered using the HTML5 DOCTYPE in Gmail.
This may cause your email to render differently than if you loaded your email in a browser.

12. Gmail’s DOCTYPE can create extra space under images.

Similar to #7, this space is also caused by the DOCTYPE.  Here are a few workarounds (these work in Hotmail and Yahoo! Beta as well):

1.) Add style display:block to the image element

<img src=“test.jpg” style=“display:block”

2.) Add align absbottom in the image element

<img src=“test.jpg” align=“absbottom”

3.) Add align texttop to the image element

<img src=“test.jpg” align=” texttop ”

4.) Add line-height 10px or lower in the containing TD

<td style=“line-height:10px”

5.) Add font-size 6px or lower in the containing TD

<td style=“font-size:6px”

For more workarounds check out this blog article: 12 Fixes for Image Spacing

Got another tip?

Got any more tips and tricks for Gmail? Feel free to share below!

Make sure your email renders nicely not just with Gmail but with all the other major email clients as well. Get started for free with our 7 day trial of Email on Acid.

Leave a Reply