Setting background colors in Gmail HTML emails not working

I’m trying to add a background color to my HTML email template that will display properly in Gmail. I want to make the entire email background have a light gray color but my current approach isn’t working at all.

Here’s what I tried using:

<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#f4f5f9" style="font-family:Verdana, Arial, sans-serif;">

The background stays white when I view it in Gmail. I’ve heard that Gmail strips out certain CSS properties and HTML attributes. Does anyone know the correct way to set background colors for HTML emails that will actually show up in Gmail? Are there any specific techniques or workarounds that work better than others?

gmail’s a bit weird with formatting. try using a table and set the bgcolor on the td cells instead. also, super important to use inline styles for the best results. hope this helps!

Gmail’s CSS sanitizer always strips background colors from body elements - no exceptions. Here’s what actually works: wrap everything in a div with inline background-color styling, then put all your email content inside that div. I’ve been building HTML emails for three years and this method hasn’t failed me once. Don’t forget to add a fallback table structure with bgcolor attributes on cells for older email clients. The trick is redundancy - use both CSS background-color and HTML bgcolor everywhere you can. Corporate Gmail accounts can be even pickier with filtering, so test your templates thoroughly before hitting send on big lists.

Yeah, Gmail’s CSS filtering is brutal - it strips out background colors on the body element along with tons of other styles. I had the same headache until I found a workaround that actually works. Wrap everything in a 100% width table and put your background colors on the table cells instead. Create a container table that spans the full email width, then nest your content in table cells. Use the bgcolor attribute directly on each td element - don’t rely on CSS alone. Pro tip: use both bgcolor attribute AND inline CSS background-color for better compatibility. I’ve tested this across Gmail, Outlook, and other major clients and it holds up well.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.