Skip to main content

Adding background images to your email in two simple steps



An updated method for adding a background image to an email body or table cells isavailable here.
Gmail
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 table 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 table attributes are fairly well supported by the major email clients... And in particular,background.
So, the first thing you can do is to wrap your newsletter content in a table ofwidth="100%", so it spans the width of the reading pane. Then, add the attribute,background="background_image.png" and it should all be roses. Here's how:
<table width="100%" border="0" cellspacing="0" cellpadding="20" background="background_image.png">
  <tr>
    <td>
      <p>Content on a pretty background image.</p>
    </td>
  </tr>
</table>
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:
body {
   background-image: url('background_image.png');
   background-repeat: repeat-y no-repeat;
   background-color: #333;
   margin: 0;
   padding: 0;
}
Surprisingly enough for a CSS solution, this does the trick in Outlook 2007 et al. The main difference between this approach and using table 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 background attribute in the body 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 table 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 margin: 0; padding: 0; in body (as above) - otherwise your table 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, <body bgcolor="#333"> (where #333 is the color of your choice). If you've already defined a fallback background-color 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

Popular posts from this blog

10 jQuery Custom Scrollbar Plugins

10 jQuery Custom Scrollbar Plugins If you ever wanted to add some custom scrollbars to your website, to scroll the contents and the default browser scrollbars just doesn’t match up with your design, than make sure you check this list of 10 jQuery custom scrollbar plugins. Hope you find the following information helpful. 1. jScrollPane – custom cross-browser scrollbars Kelvin Luck’s jScrollPane was originally developed in December 2006. It is a jQuery plugin which provides you with custom scrollbars which work consistently across all modern browsers. You can style the scrollbars using simple CSS and they degrade gracefully where JavaScript is disabled. 2. Plugin JQuery : Scrollbar This page is written in french so use Google’s translate service to translate this page to your preferred language. Download is available for the plugin.  The purpose of this plugin is to add a scrollbar to the item of your choice, to view any content which is larger than the size – vizibl...

connect ftp with gridview / display files in gridview from ftp or server

HTML Markup Below is the HTML Markup of the page, where I have an ASP.Net control  FileUpload  to upload files, a  Button control to trigger file uploads and an ASP.Net GridView control to display the files from folder. < asp : FileUpload   ID ="FileUpload1"   runat ="server"   /> < asp : Button   ID ="btnUpload"   runat ="server"   Text ="Upload"   OnClick ="UploadFile"   /> < hr   /> < asp : GridView   ID ="GridView1"   runat ="server"   AutoGenerateColumns ="false"   EmptyDataText   =   "No files uploaded">      < Columns >          < asp : BoundField   DataField ="Text"   HeaderText ="File Name"   />          < asp : TemplateField >              < ItemTempla...

Step by step installation guide for SQL Server 2012

I have so exciting news! Microsoft has released  SQL Server 2012  RTM (Code name  “Denali” ) on March 6 for manufacturing and download the evaluation edition from  http://www.microsoft.com/download/en/details.aspx?id=29066 As my laptop is 32-bit system, so I have downloaded the following files from the above link. Likewise, you can download the files for 64-bit system(x64) too. :) Finally, check your system requirements from the same link. ENU\x86\SQLFULL_x86_ENU_Core.box ENU\x86\SQLFULL_x86_ENU_Install.exe ENU\x86\SQLFULL_x86_ENU_Lang.box After downloading the above files, your system will look like below: Double click the  “SQLFULL_x86_ENU_Install.exe” , it will extract the required files for installation in the “SQLFULL_x86_ENU”  folder as shown below: Click the  “SQLFULL_x86_ENU”  folder and double click  “SETUP”  application. Checking your system requirements for installation. When you see  “SQL Server Installation Center” ...