HTML Email Full Page Background Fix (for Outlook & Webmail)
Note – we now have a better fix for this issue, which we recommend over the below fix. We’ve kept the content on this page for reference only.
Since Outlook 2007 was released, support for background images in email has been problematic. Whilst you can use the <body> tag to successfully specify a full page background image in Outlook, many webmail clients will ignore this. This has often meant that both background images and colour are also specified using a full width table, to ensure support in webmail clients.
One issue that occurs from this technique, however, is that Outlook will also render the background colour from that full width table, but not the background image, meaning that the solid background colour will display above any full page background image specified on the <body> tag in Outlook.
This fix allows you so specify a full width background image that displays in both Outlook and webmail clients, and will fall back to a solid background colour when viewed in any email client with images disabled.
Full Snippet:
<html> <head> <!--add Hotmail fixes, background colour in Hotmail is specificed on .ExternalClass--> <style type="text/css"> .ReadMsgBody {width: 100%;} .ExternalClass {width: 100%; background-color:#EDEDED !important;} </style> <!--this turns off the 100% table background colour in Outlook--> <!–[if gte mso 9]> <style> .bgemailfix{background-color:transparent !important;} </style> <![endif]–> </head> <!--this specifies the background image and colour in Outlook & other desktop email clients--> <body style="padding:0; margin:0;" background="http://www.emaildesignreview.com/wp-content/uploads/2011/08/background-fix.gif" bgcolor="#EDEDED"> <!--100% wrap table applies the background colour and background in webmail clients--> <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"> <tr> <td align="center" valign="top" class="bgemailfix" style="background-color:#EDEDED;" background="http://www.emaildesignreview.com/wp-content/uploads/2011/08/background-fix.gif"> <!--content goes here--> </td> </tr> </table> <!-- / 100% wrap table--> </body> </html>
So what’s happening here:
Using the <body> tag, we can specify a background image and colour that is supported in Outlook:
<body style="padding:0; margin:0;" background="http://www.emaildesignreview.com/wp-content/uploads/2011/08/background-fix.gif" bgcolor="#EDEDED">
Note that we can’t set CSS properties like repeat or position on this background image – the image will tile from the top left corner of the email. Note that also Outlook will add a 15px page margin, that cannot be removed.
For all other email clients, they will ignore the <body> background, so there is a 100% table with this info:
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"> <tr> <td align="center" valign="top" style="background-color:#EDEDED;" background="http://www.emaildesignreview.com/wp-content/uploads/2011/08/background-fix.gif"> <!--content goes here--> </td> </tr> </table>
We have to declare the background image using background=”” so it’s supported in Gmail.
However, Outlook will pick up the background colour from this and display it over the background image specified in <body>, therefore at the top of the email we need to apply a conditional statement to tell outlook to ignore the bgcolor:
<!–[if gte mso 9]> <style> .bgemailfix{background-color:transparent !important;} </style> <![endif]–>
However, just to add to the fun – Hotmail also picks up that conditional statement (something to do with displaying content from Word properly in email), and so this code will also disable the bgcolor in Hotmail – so we need to add an additional fix to our existing Hotmail style fix, which adds a background colour to the <div> that Hotmail wraps the email in:
<style type="text/css"> .ReadMsgBody {width: 100%;} .ExternalClass {width: 100%; background-color:#EDEDED !important;} </style>
To implement this you will need to update the page background hex code in three locations in the snippet above:
#EDEDED
…and update the background image URL in two locations:
http://www.emaildesignreview.com/wp-content/ uploads/2011/08/background-fix.gif
So now you should be all set – we’ve tested this in the major email clients, including Outlook, Gmail, Firefox and Yahoo – if you find any tweaks or use this please let us know below in the comments!
-
http://twitter.com/Hilly_2009 Stephen Hill
-
http://www.elliot-ross.co.uk Elliot Ross
-
-
http://www.facebook.com/profile.php?id=718376462 Tony Salazar
-
http://www.elliot-ross.co.uk Elliot Ross
-
-
Kevingroenendaal
-
http://twitter.com/bsisolak Brian Sisolak
-
http://www.elliot-ross.co.uk Elliot Ross
-
-
Grant Evans
-
cory c
-
Aenima