HTML email tips and tricks for Android

Coding hints for Android's mobile email platforms, including Android 4.4.4 and Android 5, as well as Android's Gmail/Gmail 5X, Outlook, and Yahoo apps.

tip banner 9 uai

1. How to prevent text from wrapping within the viewport on Android?

Android wraps text to improve readability.

If the text string's box element parent is set to align: right or centre, the text will not wrap within it. It should be noted that <font> and <span> are not considered box elements. Instead, you would add the alignment to the <td>, <div>, or <p> that contains it.

Another workaround is to set the box element parent's line-height to a value equal to or less than the font-size within the container.

2. How to write CSS that will only render on Android?

Yes. In your embedded CSS, you can use media queries.

As an example:

@media only screen and (max-device-width480px{
/* Here you can include rules for the Android and 
iPhone native email clients. 
*/
}
@media only screen and (min-device-width768px{
/* Here you can include rules for the iPad native 
email client.
*/

The Gmail app does not support media queries.

3. How to resize images to better fit on Android?

Try the code below to resize the image on mobile.

1) To the image element, apply the display:block style.

<style type="text/css">
  @
media only screen and (max-device-width:480px;) {
    
.header { width:300px;height:50px;}
  }
</style>
<style type="text/css">
  @
media only screen and (max-device-width:480px;) {
    
.header { width:300px;height:50px;}
  }
</style>

4. How to fix left side padding on Android?

This is something that Android 4.4 has a nasty habit of doing. Simply add the following CSS to your head section to fix it:

body { margin:!important}
div
[style*="margin: 16px 0"{ margin:!important

5. How to fix enlarged fonts on Android?

To control the font adjustment in Android on a global scale, try adding the following to your embedded CSS:

<style>
{-webkit-text-size-adjustnone}
</style

Alternatively, you can control text on a case-by-case basis by incorporating the following inline CSS:

<font style="-webkit-text-size-adjust: none">
Example
</font