P tags after divs in Outlook 2013 & 2016

Today I had two stacked divs. Outlook 2013 & 2016 were putting a p tag in between them. I ultimately fixed it with the following:

<!--[if mso 15]>
<style>
div + p {display: none !important; overflow: hidden !important; font-size: 0 !important; line-height: 0 !important;}
</style>
<![endif]-->
 <!--[if mso 16]>
<style>
div + p {display: none !important; overflow: hidden !important; font-size: 0 !important; line-height: 0 !important;}
</style>
<![endif]-->

Someone on the emailgeeks slack channel also suggested:

If Outlook is forcing a <p> in between two divs, you can normally override it by putting in your own and making it hidden:

<p style="margin:0;mso-hide:all"><o:p xmlns:o="urn:schemas-microsoft-com:office:office">&nbsp;</o:p></p>
Advertisements

Superscripting in Email

I work with a lot of emails that require many lines of legal, requiring superscripted elements in both the body and footer.  Previous to now, I sacrificed Outlook 07, 10, & 13 to get the best rendering in all other email clients.  No more!  The following code was the best rendering for all emails clients:

<sup style="font-size: 80%; line-height: 0; vertical-align: 5px;">
<!--[if (gte mso 9) | (IE 7)]>
<span style="font-size: 10px; vertical-align: 1px;"><![endif]-->&dagger;
<!--[if (gte mso 9) | (IE 7)]></span><![endif]--></sup>

This is my new go-to.

Thanks to EmailWizardry and TABLETRTD for inspiring this post.

AOL hack

So I don’t have to keep searching through my twitter feed every time I want to use the AOL hack, here it is:

AOl supports unicode in class but not id, therefore:

<td class=”★” id=”★”> .★:not(#★){ aol:styles }

Knowledge Dump 2

Today’s entry is about identifying rendering issues.  Some have fixes and some don’t.  Either way, you should be aware of these points.

  • Put ‘valign=”top”‘ on the containing div to vertically align side-by-side tables of different heights to the top.
  • Emails that are too tall are cut off at 1790px in Gmail, with “message clipped” at the bottom.
  • The Outlooks periodically will not read, and therefore not render, borders. This happens most often with border-left.  There is no fix for this.
  • It’s best practice to add a background-color to images.  Do not add the background-color to the td surrounding the image.
  • Android native mail app will show a declared background-color on an image as a thin side border on the image.  There is no fix for this.

A Tale of Two VMLs

Did you know 2 VML images cannot exist in the same container without looking jacked up?

While coding an email in a hybrid manner recently, I came upon this conundrum.  Two background images were necessary, but wouldn’t play nice. The first VML on the body table was working just fine, but the second background image kept appearing in the top left corner of the body in all the Outlooks rather than halfway down the email as it should have.

The solution to this was to break the email into two pieces:

<body style="margin: 0 !important; padding: 0 !important; background-color: #FFFFFF;">
    <table background="background_image.jpg" style="background-size:cover; background-position:top left; background-repeat: no-repeat; font-size: 0; mso-line-height-rule: exactly; line-height: 0px !important; mso-line-height-alt: 0; background-color: #FFFFFF;" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" valign="bottom">
        <!--[if gte mso 9]>
        <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width: 1000px; height: 800px; background-color: #FFFFFF;" valign="bottom">
        <v:fill type="frame" src="background_image.jpg" color="#FFFFFF" />
        <v:textbox inset="0,0,0,0">
        <![endif]-->
            < div align="center">
            ...
            < /div>
        <!--[if gte mso 9]>
        <p bgcolor="#FFFFFF" style="margin:0;mso-hide:all;background-color: #FFFFFF !important; font-size: 0 !important; line-height: 0 !important;"><o:p xmlns:o="urn:schemas-microsoft-com:office:office" bgcolor="#FFFFFF" style="margin:0;mso-hide:all;background-color: #FFFFFF !important; font-size: 0 !important; line-height: 0 !important;">&nbsp;</o:p></p>
        </v:textbox>
        </v:rect>
        <![endif]-->
    </table>
    <table width="100%" style="padding: 0; margin: 0;" border="0" align="center" cellpadding="0" cellspacing="0" valign="top" bgcolor="#FFFFFF">
        <div align="center">

The email is split into two main containers so that it’s no longer a “neither can live while the other survive” situation.

Now, I bet you’re wondering why there’s an ugly paragraph tag in the closing Outlook conditional after the first container. That’s the fix to the problem you will have of a rather tall gap between containers. Luckily, Stig Morten Myre found the way to combat this. Turns out Outlook’s Word rendering, in its infinite wisdom, is inserting a paragraph tag between the containers.

I found that my situation required a bit more oomph in the zeroing-out department, so I put !importants after the font-sizes and line-heights.

All of it works together seamlessly, so there is a happy endinng.

Top 6 Gmail Hacks Every Emailgeek should know

Fab Four: A technique invented by Rémi Parmentier, the fab four uses the calc() function, width, min-width, and max-width properties. The min-width property defines the column width on the desktop version while the max-width property defines them on the mobile version. The calc() function and the width property are combined as to “create a value bigger than our max-width or smaller than our min-width, so that either one of those propert(ies) is applied instead.”

lang: Justin Khoo writes of this hack: “…simulate CSS class selectors in Gmail by targeting attributes that Gmail does not strip such as the title attribute.” In my experience, this hack does not always work. My initial worries of accessibility with this hack were erased by Mark Robbin’s comments: “lang could affect accessibility if it’s read as a language but if you prefix it with `x-` it’s not read as a language so `lang=”fr”` is French but `lang=”x-fr”` means nothing.” Perfect! Just put an “x-” in front.

—-: I’m not sure who developed this hack, but I first saw it in the Litmus Comunity. It uses dashes in a hidden div to force the email to display the full width in Gmail App to bypass the mobile resizing.

img width em: Discovered by Mark Robbins, this hack combats the resizing antics of Gmail on iOS by using ems on the width and font-size properties for images so that when the font-size is increased, the image will be increased as well.

fake position: absolute: Posted on the Rebelmail blog, this hack works in modern email clients like iOS, Android, Apple Mail, AOL, etc. Absolute positioning is achieved with 3 nested divs. First, the container div, then one set to display inline-block and set with margin-top and margin-left, and lastly, the div doing the heavy lifting by being set at max-width and max-height set at 0. This div takes up no space on the page, but the overflow can still be seen, thus acting like position: absolute.

max-height:0: This property is used in conjunction with display: none; line-height: 0, font-size: 0, and overflow: hidden to hide content.

This post was inspired by Mark Robbins’ tweet.