Skip to main content
Litmus Litmus
  • Capabilities
    • What’s New
    • Why Litmus
    • Campaign Development
    • Collaboration & Reviews
    • Pre-Send Testing
    • Insights & Analytics
    • Technology Integrations
  • Solutions
    • Email Service Provider
      • Adobe Marketo
      • Oracle Eloqua
      • Oracle Responsys
      • Salesforce Marketing Cloud
      • Acoustic Campaign
      • SAP Marketing Cloud
    • By Industry
      • Marketing & Ad Agencies
      • Financial Services
      • Retail & eCommerce
      • Software & Technology
    • By Role
      • Designers & Developers
      • Marketers
      • Marketing Leadership
  • Pricing
    • All PlansSee Solutions for Companies of All Sizes
    • Basic PlanPerfect for one-person email teams
    • Plus PlanIdeal for 2- to 3-person email teams
    • Enterprise PlanIdeal for agencies and email teams of 4+ people
  • Resources
    • Resource Center
      • Litmus Live
      • Blog
      • Ebooks & Reports
      • Webinars & Events
      • Customer Success Stories
      • Reviews
      • Community
    • Free Tools
      • Gmail Promotions Builder
      • Email Client Market Share
      • Gmail Tabs Check
      • Litmus Scope
      • Templates
  • Company
    • Our Story
    • Careers
    • Leadership
    • News
    • Partner with Litmus
  • Login Try for Free
Login Try for Free
Litmus Blog

Email marketing best practices to guide your strategy

  • Share page through Facebook
  • Share page through Twitter
  • Share page through Linkedin
  • Share page through e-mail
Read Time: 3 min

The Best Way to Code Background Colors for HTML Email

Justine Jordan
Justine Jordan
on March 27, 2018

The lack of any sort of coding standard makes creating HTML emails hard. Even something as simple as applying background colors to email elements can be tricky to get right. In fact, there are a number of email clients that display background colors differently depending on how they’re coded.

Read on to get the scoop and find the one bulletproof way to code background colors in email for consistent results across the board.

Why use background colors in email?

Unlike images, background colors render across all email clients and don’t add to email loading time, making your email design more special without increasing email weight.

Plus, background colors also help to establish a hierarchy and organize content, making it easier for your subscribers to read your emails, even when images are turned off.

Here’s an example of how we use background colors to differentiate between content in our newsletter. With images turned off, you can see how the different background colors help maintain the hierarchy of the email content.

Background Colors In Email - Litmus Newsletter
Images On
Background Colors - email newsletter 
Images Off

How to code a background color?

Usually, background colors are applied to a few common HTML elements: <body> <table> <td> <div> and <a>. Depending on your experience and coding style, you might use one of six (yes, six) different ways to apply background colors to elements in your email:

  • Using the HTML bgcolor attribute with a 3-digit hexadecimal color code
  • Using the HTML bgcolor attribute with a 6-digit hexadecimal color code
  • Using the HTML bgcolor attribute with an RGB color value
  • Using the background-color CSS property with a 3-digit hexadecimal color code
  • Using the background-color CSS property with a 6-digit hexadecimal color code
  • Using the background-color CSS property with an RGB color value

Three digit HEX codes in email

Using 3-digit, or shorthand, HEX codes is not a great idea. When 3-digit HEX codes are used in <table> and <td> tags, blue (or sometimes black!) backgrounds result, with no regard to the color specified:

Three digit HEX codes in email

RGB values in email

RGB values didn’t fare much better, resulting in a few lovely shades of green (despite specifying values for white and gray):

RGB values in email

In some cases, RGB values used with the HTML bgcolor attribute didn’t show up at all.

The best way to code a background color

The most reliable way of coding background colors is to use the HTML bgcolor attribute with a 6-digit HEX code:

<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”600″ bgcolor=”#ffffff”>

<td bgcolor=”#ffffff”>

Depending on the specific breakdown of the email clients your audience is using, CSS background-color with a 6-digit HEX code is very reliable as well. Email clients like Gmail, Apple Mail, and Outlook show great support for the CSS background-color attribute. Still, while some methods work consistently on certain elements, sticking to one background color strategy is easier than trying to keep specific background color quirks straight.

For simplicity and the best support across clients, the old school HTML bgcolor attribute and 6-digit HEX codes are the most popular method.

Test your emails before you send

Preview you your emails in dozens of popular email clients and devices and catch rendering issues—including background colors that don’t display as intended—with Litmus Email Previews.

Learn more →

Categories
  • Tips & Resources
Justine Jordan
Justine Jordan
See All of Justine Jordan's Posts

Most Popular

  1. May 16, 2017

    Litmus Builder Essentials: How Teams Can Use Our Email Builder

    Product
    Read Time: 7 min
  2. September 16, 2020

    The Ultimate Guide to Dark Mode for Email Marketers

    Tips & Resources
    Read Time: 16 min
  3. February 5, 2021

    How to create an "Add to Calendar" link for your emails

    Tips & Resources
    Read Time: 28 min

How does your email really look?

Preview across 90+ email clients, apps, and devices.

See it in Litmus (for free!)

Keep up with the latest in email

Get the best email marketing and design tips, stats, and resources, delivered to your inbox.

Subscribe
Litmus Email marketing made better

Contact
675 Massachusetts Ave., 10th Floor
Cambridge, MA 02139
+1 (866) 787-7030
hello@litmus.com

  • Capabilities
    • What’s New
    • Why Litmus
    • Campaign Development
    • Collaboration & Reviews
    • Pre-Send Testing
    • Insights and Analytics
    • Technology Integrations
  • Resources
    • Blog
    • Customer Success Stories
    • Webinars & Events
    • Community
  • Company
    • Our Story
    • Careers
    • Leadership
    • News
  • Support
    • Contact Us
    • Help Center
    • System Status
    • Trust Center
Copyright © 2021 Litmus Software, Inc. 2005-2020
  • Privacy Policy
  • Terms of Service
twitter facebook linkedin youtube-play instagram search envelope