Why does Gmail automatically add im class wrapper to email HTML content

I’ve been working on HTML emails lately and noticed something weird happening in Gmail. When I send my carefully crafted HTML emails, Gmail seems to automatically wrap parts of my content with a div that has class="im" attribute.

<span class="im">
<!-- my email content gets wrapped here -->
</span>

This is really frustrating because I never added this wrapper myself. I’ve checked my original email template multiple times and this class is definitely not in my code. The problem is that this automatic wrapping makes some of my text appear in purple color while other parts stay normal.

Has anyone else experienced this issue with Gmail? What causes Gmail to inject these im class containers into email HTML? Is there a way to prevent this from happening or work around it?

Any help would be appreciated.

Gmail’s algorithm mistakenly identifies your content as quoted text from previous conversations. The im class indicates “important” status, but it’s primarily used by Gmail to highlight what it perceives as quotes, resulting in the purple text styling. Through my experience, I’ve found that Gmail is sensitive to certain HTML patterns—like indentation, specific CSS properties, or the arrangement of text blocks. To minimize these issues, utilize inline styles rather than CSS classes and avoid uniform margin or padding across elements, as this can signal structured quote formatting to Gmail. Testing your templates in a variety of email clients is crucial, as this behavior is unique to Gmail.

I feel ya! Gmail’s im wrappers r super frustrating. I’ve noticed simple HTML works better - steer clear of <blockquote> tags. Those > symbols can set it off too. It’s annoying, but we gotta deal with it, right?

Gmail wraps quoted content with the im class when it thinks parts of your email are quotes from earlier messages in the thread. That purple styling you’re seeing? That’s Gmail’s default look for quoted text.

This kicks in when your HTML matches patterns Gmail associates with forwards or replies. Even fresh emails can trigger it if certain HTML structures or formatting look like reply content.

To reduce this happening: skip indentation patterns, don’t use blockquote elements, and avoid text that starts with typical reply phrases like ‘On [date] so-and-so wrote.’ Keep your HTML simple - deeply nested divs confuse Gmail’s parser.

There’s no foolproof way to stop this completely since it’s baked into Gmail’s automatic content detection.

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