Coding background colors sounds like a simple task right? The truth? Even this minor bit of styling has some pitfalls, and there are a few considerations that need to be made to get consistent rendering across email clients.
And it’s not just developers that need to appease the inbox gods. With Dark Mode gaining momentum, there are even more environments to be aware of, some of which will require email designers to take extra care when applying background colors in their designs.
In this blog post, you’ll learn:
Why use background colors in email?
Putting a background color strategy into place meets a few needs when it comes to elevating your email program. From a technical standpoint, implementing background colors doesn’t add any load time to your emails, and they’re still visible even when images are turned off. They can help separate content, call out messaging, or set an email apart from others in your subscriber’s inbox, potentially increasing engagement among your audience.
Stand out in the inbox
You can create an impactful opening experience—like this email from Blurb.
The hero area packs a punch. The bold orange background makes an impact by contrasting against the blue of the logo, elevating the brand identity. Once the reader scrolls past the hero area, secondary content sits on a white background, offering the ideal reading experience for larger bodies of copy.
Separate out sections
If you’ve got a long email, color is a great way to visually separate different content blocks so it feels more digestible.
Promotional emails from coffee house giant Starbucks can be quite lengthy, with multiple promotions housed within a single email. To help sections stand apart from each other, different background colors are used.
Elevate brand identity
Gradients are part of Marketing Agency 1973 Ltd’s brand identity, which is why you often find bold linear gradients in the background of their emails. Background gradients can make compositions appear more dynamic, and even encourage the subscriber to scroll.
So what’s the best way to bring these techniques into your email development? I asked my teammate and developer of Litmus emails, Carin Slater, to give us the lowdown on coding solid and gradient backgrounds.
How to code a solid background color in email
Background colors can be coded in multiple ways and in multiple places. But each method is not equally supported among email clients. Here’s a quick chart of which background style code and color code method works for the top email clients.
Email client support for background colors
We all know email clients can be a bit persnickety. So what’s the best way to code background colors so it works across all email clients? I’ll walk you through our recommendation and why.
1. Use tables and table cells
There are four places in your HTML that you can add a background color:
The safest place to add the background color is on a table or a table cell.
The <body> tag is deleted in Yahoo and AOL, so any background color applied there won’t show up in those email clients. And placing a color on a wrapping <div> after the body would work everywhere except Outlook clients since they don’t support <div> tags in emails.
To get the widest range of email client support, wrap your entire email in a 100% width <table> tag and put your background color there. And use table cells <td> for sections of your email so you have greater flexibility in coloring specific content blocks.
2. Add color with a CSS property and HEX color codes or RGB values
Background colors can be coded in multiple ways:
- Using the bgcolor HTML attribute
- Using the CSS property background-color
- Using the CSS shorthand property background
- Using the 6 digit hexadecimal color code
- Using the 3 digit hexadecimal color code
- Using RGB color values
As far as how to put the background color on your table or table cell, you should use a CSS property.
Testing the two CSS property methods—background-color and background—we found they both have the same, consistent results as long as you are only adding color (no images). According to caniemail.com, using the background property for anything other than adding a color may result in your color not showing up.
The bgcolor HTML attribute didn’t fare well in Outlook, with inconsistent support for 3-digit HEX codes. And the use of RGB and RGBA values resulted in the incorrect color, or the color being dropped completely.
Here’s our background color test using the various methods in Outlook so you can see for yourself:
In other email clients, the 3-digit HEX code rendered well, but the RGB and RGBA values resulted in incorrect colors when applied to the bgcolor HTML attribute.
After all our testing, we came to one conclusion: Stick with the CSS properties, and use 3 or 6-digit HEX codes or RGB values. Those worked across all email clients.
Introducing opacity with the alpha for the RGBA value wasn’t supported in Outlook, Web.de, or GMX.de, but had decent support otherwise.
So your final code should look something like this to color the whole background of a table:
Blog – Litmus