Background images not working in Outlook 2007 and later

元气小坏坏 提交于 2019-11-28 05:30:27

Email-reader support for background images

Outlook 2007 and later only supports 2 ways to display a bg image:

  • Using the HTML background attribute on the body tag
  • Using the inline background-image style on the body tag

In both cases, Outlook scales the image differently than other email readers, and there's no way to prevent the bg image from tiling.

So for all practical purposes, background images aren't an option for supporting a wide range of email readers. Instead, you'll need to make do with foreground images (img tags).

Overlaying elements is not an option

Outlook 2007+, Gmail, Hotmail, and Yahoo Mail don't support CSS positioning. As a result, there's no way to place a text element on top of a foreground image.

When slicing up the email into different areas (typically using HTML tables), each area can either be a text element or a foreground image. But you can't have both in the same area (i.e., you can't have two elements occupying the same space or overlapping).

Solutions

For areas where there's an image with no text on top of it, that part of the email can be cut as a separate foreground image.

For areas where there's an image with text on top of it, there are 3 options:

  1. Cut the text as part of the image. This hurts the usability of the email, and it's especially problematic for users who have images disabled by default (as they won't initially see the text).
  2. Display the image as a background image, with the understanding that users of Outlook 2007+ will not see the image (graceful degradation).
  3. Do not attempt to display the background image in any email reader.

In moderation, option #1 is usually safe and reasonable. But when used heavily, it leads to a very high ratio of images to text in the email, which may trigger some spam filters. Before making heavy use of option #1, test the email in a variety of spam filters.

Before proceeding with options #2 or #3, you may need to clear it with the designers (as either one compromises the design in Outlook 2007+). In the bigger picture, background images should be used sparingly when designing emails. It may be helpful to point out to the designers the impact of using background images.

John

Outlook only supports background images in the body tag unless you use VML. Check this out for VML: http://backgrounds.cm/

Here is an example of it working in the body tag.

I think you'll find this really handy: http://www.campaignmonitor.com/css/

Outlook 2007-13 doesn't support the background-image property, so there is not any good way to solve for this.

Based on personal experience: To get the most consistent experience across email clients, I would redesign the email to not require a background image.

background-image is not supported in Outlook or Gmail on Android 2.3. See: http://www.campaignmonitor.com/css/

I usually use background-color as a fallback, or if the background image is necessary, make the text part of the image.

You can do this using the correct VML. The below codepiece works best for me:

<table>
<tr>
<td background="http://fpoimg.com/300x300?text=I%20am%20a%20background%20image" width="300" height="300">
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" 
    style='width:300px;height:300px;position:absolute;bottom:0;left:0;border:0;z-index:-3;' 
    src="http://fpoimg.com/300x300?text=I%20am%20a%20background%20image" />
<![endif]-->
<p>Put the rest of your content here</p>
</td>
</tr>
</table>

Background image will not support in outlook 2007+ Use VML ( Vector Markup Language (VML) is an XML-based file format for two-dimensional vector graphics. ) to get support eg :

   <div>
     <!--[if gte mso 9]>
     <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
      <v:fill type="tile" src="pink_bkg.png.png" color="#fff"/>
     </v:background>
     <![endif]-->
     <table>
       <tr>
         <td>
         </td>
       </tr>
      </table>
   </div>

Help Link : http://backgrounds.cm/

Outlook Specific /* Your Outlook-specific CSS goes here. */

‘mso 9’ is Office 2000 Outlook 2000 - Version 9 Outlook 2002 - Version 10 Outlook 2003 - Version 11 Outlook 2007 - Version 12 Outlook 2010 - Version 14 Outlook 2013 - Version 15 http://templates.mailchimp.com/development/css/outlook-conditional-css/

We can add this way :-

Add the following right after the opening tag…

<table cellpadding="0" cellspacing="0" border="0" height="92" width="100%">
  <tr>
    <td background="https://i.imgur.com/YJOX1PC.png" bgcolor="#7bceeb" valign="top">
      <!--[if gte mso 9]>
      <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;height:92px;">
        <v:fill type="tile" src="https://i.imgur.com/YJOX1PC.png" color="#7bceeb" />
        <v:textbox inset="0,0,0,0">
      <![endif]-->
      <div>

…and this right before the closing tag.

      </div>
      <!--[if gte mso 9]>
        </v:textbox>
      </v:rect>
      <![endif]-->
    </td>
  </tr>
</table>

October 2018 - Tested in Outlook 2016

Figured I'd chime in with the VML snippet that worked for me. Taken from https://medium.com/@ka.robinson82/https-medium-com-ka-robinson82-fargo-email-6907f00fed16

<! — [if gte mso 9]>
<v:image xmlns:v=”urn:schemas-microsoft-com:vml” style=”width:525pt; height:348.75pt;” src=”image.jpg" /> 
<v:rect xmlns:v=”urn:schemas-microsoft-com:vml” fill=”false” stroke=”false” style=”position: relative; width:525pt; height: 161.25pt; top: 187.5pt;”>
    <v:textbox inset=”0,0,0,0"> 
<![endif] 

<!-- Content -->

<!--[if gte mso 9]>   
    </v:textbox>
</v:rect>
<![endif]-->

Other VML snippets worked to an extent but I had issues with the image disappearing after leaving the email and coming back, or not loading until the background was clicked on.

I've just come across this problem while creating bulk emailer templates in MailChimp.

While the Outlook client software allows only body tag backgrounds, these are stripped out by webmail sites like Outlook webmail (hotmail), gmail etc.

The same is also true in reverse... Outlook client strips out table background images, whereas webmail clients allow table backgrounds.

Solution: use both:

<body background="image.jpg">
<table width="100%" background="image.jpg">

In Mailchimp itself, this seems to display erroneously - you can see the edge of the body background around the edges of the table background, but by the time it reaches the recipient, either one or the other is stripped out depending on whether they're using Outlook client software or Hotmail/Gmail webmail.

I'm yet to try this in other email client programs or webmail, so I don't know if there are others that would display both. If anyone has tried this method with other email client software or webmail other than Hotmail or Gmail, I'd very much like to know if this fix is universal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!