An updated method for adding a background image to an email body or table cells isavailable here.
We often get asked about the best way to add a background image to an email newsletter. Well, the good news is that there's a reliable way to get a repeating background image to surround your content in most major email clients, including Gmail and Outlook 2007! In this post, we'll walk through two techniques which can be combined to give your design some background image love.
The attribute approach
Look, I've written some darn ugly code in my time, but I still get itchy when I use tables. In so much as we shy from them, it should come as no surprise to you folks at home that a fair few attributes are fairly well supported by the major email clients... And in particular, .
So, the first thing you can do is to wrap your newsletter content in a table of
, so it spans the width of the reading pane. Then, add the attribute, and it should all be roses. Here's how:
So far so good. The table will expand downwards as you add more content, so a repeating background image will tile just nicely until the end of your email.
The good news is that this works in most major email clients, including Gmail. Notable exceptions are Outlook 2007 and 2010, plus Lotus Notes 6 and 7.
The CSS approach
Not wanting to keep the ever-demanding Outlook 2007 and its relation, Outlook 2010 away from the action, we turned to a crafty technique for getting background images to work in Outlook 2007. The code looks something like this:
Surprisingly enough for a CSS solution, this does the trick in Outlook 2007 et al. The main difference between this approach and using attributes is that in some email clients, the background image will extend the entire height of the reading pane, instead of simply the height of the email. However, unless you have a fairly short email (less than the height required for the scrollbar to kick in), you won't be able to tell the difference.
I've also had it pointed out that using the attribute in the tag works in a similar fashion. Unfortunately, it doesn't seem to display a background image in Outlook XP. Considering you have to use some CSS anyway (see below), you might as well stick to our CSS approach.
So are you thinking what I'm thinking?
"By your powers combined!"
By using both the attribute and CSS styles in your HTML email, you pretty much have the entire spectrum of major email clients covered. Don't forget to set in (as above) - otherwise your background image won't be flush with the image defined in your CSS styles.
And finally, if you're really finicky, you can define a fallback color for Lotus Notes 6 & 7 by using, (where is the color of your choice). If you've already defined a fallback using CSS, then this will only display in these earlier versions of 'Notes.
Well, Let me know below if you have any questions, or have been using a similar alternative!
Comments
Post a Comment