Horizontal Scroll on HTML Tables in Gmail for Android Not Working

Viewed 1291

So I'm trying to send an HTML email (using PHP if that matters) with wide tables in it and have it formatted as horizontally scrollable in Gmail for Android and iOS. Anyhow, no matter what I do, I can't get a horizontal scrollbar to appear in the Gmail app for Android, although it does seem to work in Gmail on the web. I've tried this with table width 100% and no table width and min-width and nothing works. I have also tried it with overflow-x: auto instead of scroll.

Gmail for Android just shows up to a certain column and then, if you swipe right to scroll, it takes you to the previous email. What I have noticed is that, if I go into my Gmail for Android settings and disable "Auto-fit messages," it solves the problem. Unfortunately, that's the default setting and I can't count on all of my readers to disable it (is there a way to disable it in my html?).

Here's my html for the email.

<html>
    <head></head>
    <body>
        <div style="overflow-x: scroll;">
            <table style="width: 100%;">
                <tr>
                    <th>Article</th>
                    <th>Entrance</th>
                    <th>Page Views</th>
                    <th>Author</th>
                    <th>Images in Article</th>
                    <th>Links in Article</th>
                    <th>Links to Article</th>
                    <th>Meta Title</th>
                    <th>Google Referrers</th>
                    <th>AMP Traffic</th>
                    <th>Users</th>
                </tr>
                <tr>
                    <td>How to Scroll in Gmail</td>
                    <td>500,000</td>
                    <td>700,000</td>
                    <td>John Smith</td>
                    <td>25</td>
                    <td>200</td>
                    <td>How to Scroll in Gmail: a Comprehensive Guide</td>
                    <td>2,000,000</td>
                    <td>3,000,000</td>
                    <td>100,000,000</td>
                </tr>
            </table>
        </div>
    </body>
</html>

Any ideas? Or is it impossible to make a horiz scrollbar appear in the Gmail app, because Google wants to have its swipe right thing?

1 Answers

I would seriously advise against horizontal scroll for something as important as a data table. Gmail mobile app default practise for side scroll/swipe is to switch emails, as you've seen.

ActionRocket ran a test of this with their own newsletter a few years back and the email clients that actually did support it were Apple Mail (Mac & iOS), Outlook for Mac and Gmail Webmail. The coverage is actually quite small and you would need a reliable fix for the rest of the email clients you would be sending to.

I would suggest a different approach to your table, such as stacking the column header and column content together in a group like below (also in Codepen):

<style type="text/css">
  @media only screen and (max-width:1300px) {
    .row { display:block!important; width:100%!important; }
  }
</style>
<div style="overflow-x: scroll;">
  <table style="width: 100%;">
    <tr>
      <th>Article</th>
      <th>Entrance</th>
      <th>Page Views</th>
      <th>Author</th>
      <th>Images in Article</th>
      <th>Links in Article</th>
      <th>Links to Article</th>
      <th>Meta Title</th>
      <th>Google Referrers</th>
      <th>AMP Traffic</th>
      <th>Users</th>
    </tr>
    <tr>
      <td>How to Scroll in Gmail</td>
      <td>500,000</td>
      <td>700,000</td>
      <td>John Smith</td>
      <td>25</td>
      <td>200</td>
      <td>How to Scroll in Gmail: a Comprehensive Guide</td>
      <td>2,000,000</td>
      <td>3,000,000</td>
      <td>100,000,000</td>
    </tr>
  </table>
</div>

<br>
<br>
<br>
<br>
<br>
<br>

<table border="0" cellpadding="0" cellspacing="0" style="width:100%;" role="presentation">
  <tr>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;" colspan="2">
            Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            How to Scroll in Gmail
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Entrance
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            500,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Page Views
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            700,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Author
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            John Smith
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Images in Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            John Smith
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Links in Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            25
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Links to Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            200
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Meta Title
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            How to Scroll in Gmail: a Comprehensive Guide
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Google Referrers
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            2,000,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            AMP Traffic
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            3,000,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Users
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            100,000,000
          </td>
        </tr>
      </table>
    </th>
  </tr>
</table>

Obviously I've left styles from another project in there but it gives you an idea of the potential. It's als more code but a great alternative to keep in mind for smaller screens, across the board.

Related