Html Email Template on Android not responsive

7.6k views Asked by At

I have created an email template utilizing tables,tr,td's. All seems to be ok except the fact that on android phones it is not re-sizing to fit the screen.. it works perfectly on apple products.. I have searched some online and the word seems to be that android has disabled responsiveness for some reason. There has to be a way around this as most all emails are checked on mobile phones and quite a few of them are on android.

5

There are 5 answers

0
Ted Goas On BEST ANSWER

As some other have noted, Gmail and some Android stock email clients do not support media queries. To cover these clients, you need Hybrid Design.

Hybrid design achieves a responsive, shape-shifting layout without using media queries. At its core, it uses max-width and min-width to impose rigid baselines (allowing some movement) and imposes a fixed, wide width for Outlook who is shackled to desktop anyway. Once a mobile-friendly baseline is set, media queries progressively enhance the email further in clients that support it (like iOS Mail).

Here is a basic 2-column scaffolding from Fabio Carneiro's code samples on GitHub (all credit to him!):

<!doctype html>
<html>
 <body style="margin:0;">
  <center>
   <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">




    <!-- // 2-COLUMN SCAFFOLD [CENTERING, FLUID] -->
    <tr>
     <td align="center" height="100%" valign="top" width="100%">
      <!--[if mso]>
      <table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
      <tr>
      <td align="center" valign="top" width="660">
      <![endif]-->
      <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:660px;">
       <tr>
        <td align="center" valign="top" style="font-size:0;">
         <!--// DEVELOPER NOTES:
          1. Setting font-size:0; is necessary to ensure
             that there is no extra spacing introduced
             between the centering divs that wrap each
             of the columns. //-->

         <!--[if mso]>
         <table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
         <tr>
         <td align="left" valign="top" width="330">
         <![endif]-->
         <div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
          <!--// DEVELOPER NOTES:
           1. To have each column center upon stacking,
              wrap them in individual divs, set the same
              max-width and width as the table within it,
              and set display to inline-block; using
              vertical-align is optional.

           2. Setting min-width determines when the two
              columns of this block will wrap; in this
              case, when the total available width is
              less than or equal to 480px. //-->

          <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
           <tr>
            <td align="center" valign="top">
 
             <!-- // REPLACE WITH BLOCK -->
             <p style="background-color:#2BAADF; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">LEFT</p>
             <!-- REPLACE WITH BLOCK // -->
 
            </td>
           </tr>
          </table>
         </div>
         <!--[if mso]>
         </td>
         <td align="left" valign="top" width="330">
         <![endif]-->
         <div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
          <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
           <tr>
            <td align="center" valign="top">
 
             <!-- // REPLACE WITH BLOCK -->
             <p style="background-color:#51BBE5; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">RIGHT</p>
             <!-- REPLACE WITH BLOCK // --> 
 
            </td>
           </tr>
          </table>
         </div>
         <!--[if mso]>
         </td>
         </tr>
         </table>
         <![endif]-->
        </td>
       </tr>
      </table>
      <!--[if mso]>
      </td>
      </tr>
      </table>
      <![endif]-->
     </td>
    </tr>
    <!-- 2-COLUMN SCAFFOLD [CENTERING, FLUID] // -->




   </table>
  </center>
 </body>
</html>

There are more scaffolds and patterns in that repo and elsewhere, but this shows the basic principle in action.

4
NullByte On

Have you tried setting up Viewport metatag to your html template?

<meta name="viewport" content="width=device-width, initial-scale=1">
0
ja408 On

If your talking about the Gmail app on Android (which is what you tagged this question as) the app itself does not mobilize with media queries or style tags, it strips them as you have found. Make sure you inline as much as possible to get the best support across email clients.

There is a way to get it to mobilize by using a combination of fluid and fixed width tables. But it won't be pixel perfect. Think about fixed width tables as the blocks inside a fluid table (width=100%). Tables will stack on top of one another once they reach the width they are set for. This is of course for any multi column layout. Single column is the safest approach because there is no need to focus on stacking. Don't hesitate to use tables nested in tables that are nested in tables. For the approach I mentioned above of using fluid and fixed width tables, for a two column layout you would have your outer table be 100% width and two fixed width tables inside that table that are a specific width and aligned right and left.

It is possible to get it to look decent in Gmail app, but there are two concepts you have to ask yourself, are you going for graceful degradation or lowest common denominator?

Graceful degradation meaning it looks great in a lot of email clients and decent in gmail app or lowest common denominator being single column and designing around that.

0
aerospatiale On

I definitely agree with setting:

<meta name="viewport" content="width=device-width, initial-scale=1">

I would also suggest using an css-inlining tool such as this one http://templates.mailchimp.com/resources/inline-css/ (if your external source doesn't already do it on your behalf) to ensure that gmail picks up the styles.

In addition, in terms of general scaling issues in Gmail, I would suggest adding the following block just before your closing body element (as recommended here: http://freshinbox.com/blog/gmail-on-ios-increases-font-size-on-some-emails/):

<div style="display:none; white-space:nowrap; font:15px courier; line-height:0; color: #ffffff;">
    ----------------------------------------
</div>
0
Martina Sartor On

Android doesn't support responsive emails but there are some workarounds. For example you can change all the to . This will solve the problem. It will also make the text bold in those cells but you can change the styles to force it to render as you like.

If you are talking about Gmail on Android, Gmail app doesn't support responsive either but you can force it to render as desktop. Unfortunately no workarounds for Gmail and this will be the only solution so far.

It is all explained step by step here: Hot to get a responsive email to work on Android