In one of our previous articles on Good coding practices, We had already pointed out problems with the interpretation of background images.

This time, Litmus, which provides a rendering and deliverability testing service, recently published a article revealing a concern regarding the way to use a background color and the best way to encode it. Their tests were conducted on various webmail services (Hotmail, Gmail, AOL, Yahoo) as well as on the latest versions of browsers (Internet Explorer, Chrome, Firefox).
In the creation of an email, the background color can be used as such or to compensate for the non-display of the background image. It is mainly used in tags <body>, <table>, <td> and <div>. According to the coding conventions, there are 6 ways to encode the background color:

The attribute bgcolor with 3-digit hexadecimal => bgcolor=’#DDD’

The attribute bgcolor with 6-digit hexadecimal => bgcolor=’#DDDDDD’

The attribute bgcolor with an RGB value => bgcolor=’rgb(221, 221, 221)’

The CSS property background-color with 3-digit hexadecimal => style=’background-color:#DDD’

The CSS property background-color with 6-digit hexadecimal => style=’background-color:#DDDDDD’

The CSS property background-color with an RGB value => style=“background-color:rgb(221, 221, 221’)

First of all, I invite you to use the inline attributes (bgcolor in this case) to the fullest extent possible, because legacy webmail and messaging tools interpret CSS properties (inline or not) incorrectly.

Regarding the different variations of the bgcolor, in parallel with the many litmus tests, I propose a quick rendering test between Internet Explorer and Firefox.

The First test shows that under Internet Explorer 8, The use of bgcolor and 3-digit hexadecimal is misinterpreted because the background is black instead of gray. On the Second test with Firefox 8, The background color defined with the RGB method is green instead of gray. Thanks to the two examples, it is clear that the best way to code the background color is of’use the bgcolor attribute with 6-digit hexadecimal.

Return of the bgcolor property in Internet Explorer

Return of the bgcolor property in Internet Explorer

Return of bgcolor in Firefox

Return of bgcolor in Firefox

Ultimately, this study shows that with so many versions of messaging and webmail tools and so many different rendering engines, the best way to have a consistent HTML email on any platform is to code your emails using the rules of the old school.

If you have any questions, comments, a project, or suggestions, please do not hesitate to Contact NSP who puts all his know-how and expertise at your disposal.

Respond to this article by leaving a comment, share it with your friends and acquaintances, and sign up for our RSS feed to be informed as soon as new articles are published.

Process the potential of your data
and make the right decisions to take action.

You might also like