Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmail html email background color

Tags:

html

email

IS there any way to put color as background in HTML email for gmail?

I used this for making body background grey but it doesnt work

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#e2e3e7" style="font-family:Arial, Helvetica, sans-serif;">
like image 609
Tomas Smith Avatar asked Feb 29 '12 05:02

Tomas Smith


People also ask

Can you add a background color to an email in Gmail?

On your computer, open Gmail. See all settings. Next to Themes, click View all. In the themes window, select your theme.

How do you put a background color on HTML?

To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.


3 Answers

Wrap your email in a single celled table with 100% width and height and set the background colour for that cell.

<table width="100%" height="100%">     <tr>         <td width="100%" height="100%" bgcolor="#e2e3e7">              <!-- "Content" table goes here -->             <table width="600" align="center" bgcolor="#ffffff">              </table>          </td>     </tr> </table> 
like image 194
digout Avatar answered Sep 22 '22 01:09

digout


Gmail (and other mailers) remove all css that is not inlined. So the hack of the tables works only because you define the color inline. You don't need a table, instead use

<body style="background-color:#242a30;">
like image 25
Mermoz Avatar answered Sep 20 '22 01:09

Mermoz


I just had to do the same thing. If you put your email body into a table, you can set the table's bgcolor and that will work.

I had <body bgcolor='lightcyan'>, then I changed it to <body> <table bgcolor='lightcyan'> and put my content into that table.

like image 35
codesforcoffee Avatar answered Sep 19 '22 01:09

codesforcoffee