Skip to main content

Our email CSS engine is open source. Give it a star on GitHub 

Emailens
Blog

Gmail CSS Support: What Gmail Keeps, Strips and Rewrites

Gmail keeps one <style> block in the head up to 16KB and rewrites your class names, but drops external stylesheets, web fonts and unsupported properties, and its apps strip the <style> block for non-Google accounts, so anything critical must be inline.

What to do instead in Gmail

Inline CSS for Gmail compatibility

instead
<div style="background-color: #6d28d9; padding: 32px;">
  <h1 style="color: #fff; font-size: 24px;
             font-family: Arial, sans-serif; margin: 0;">
    Hello
  </h1>
</div>
Show the original
before
<style>
  .header { background-color: #6d28d9; padding: 32px; }
  .title  { color: #fff; font-size: 24px; }
</style>
<div class="header">
  <h1 class="title">Hello</h1>
</div>

A free account opens all 21 clients and keeps your checks for 7 days. Create a free account →

Philippe Kam, founder of Emailens · Published 4 Mar 2026 · Updated 28 Oct 2026

@emailens/engine 0.18.22 · data last changed 10 Nov 2026

Part of the HTML email guide · all guides

Gmail has a reputation for stripping all CSS. It does not: it keeps a head <style> block and supports media queries, flexbox and background images. Here is what survives, what is removed, and where the web and app versions differ.

How Gmail's sanitizer handles your CSS

When Gmail receives an HTML email, it runs it through a sanitizer that:

  1. Keeps one head <style> block, with limits: a block in the <body> or over 16KB is removed whole, and external <link> stylesheets are always removed
  2. Rewrites class names: adds a per-message prefix (e.g., class="m_2931abc") and rewrites your selectors to match
  3. Filters CSS properties: unsupported ones such as position and animation are removed, inline or not
  4. Strips scripts: no JavaScript runs

The apps add one condition: for an account that is not a Google account, the iOS and Android apps remove the <style> block and media queries too. Inline styles are the only thing guaranteed to reach every Gmail reader.

The 16KB cap on the <style> block is separate from the 102KB limit on the whole message, past which Gmail clips the email behind a “[Message clipped]” link. What counts toward that limit and how to stay under it is in Gmail clipping at 102KB.

Gmail CSS support: properties that work inline

These inline CSS properties survive Gmail's sanitizer:

For the full compatibility matrix, see the Gmail CSS support reference.

CSS that Gmail strips or limits

A Gmail-safe email template

Here's a complete email structure that survives Gmail's sanitizer. Every style is inline, layout uses tables, and no declaration depends on <style> blocks:

Gmail-safe HTML
45 lines
<!-- This email survives Gmail's sanitizer -->
<table role="presentation" width="100%" cellpadding="0" cellspacing="0"
  style="background-color: #f6f6f6;">
  <tr>
    <td align="center" style="padding: 40px 20px;">
      <table role="presentation" cellpadding="0" cellspacing="0"
        style="background-color: #ffffff; max-width: 600px; width: 100%;">
        <tr>
          <td style="padding: 30px;">
            <!-- Every style is inline, nothing depends on <style> -->
            <img src="https://example.com/logo.png"
              alt="Company" width="120" height="36"
              style="display: block; border: 0;" />

            <p style="margin: 24px 0 16px; font-family: Arial, sans-serif;
              font-size: 24px; font-weight: bold; color: #333333;">
              Welcome!
            </p>

            <p style="margin: 0 0 24px; font-family: Arial, sans-serif;
              font-size: 14px; line-height: 1.6; color: #666666;">
              Your content here. Every text element has its own
              font-family declaration because Gmail doesn't inherit
              reliably.
            </p>

            <!-- Button as a table cell (not a styled <a>) -->
            <table role="presentation" cellpadding="0" cellspacing="0">
              <tr>
                <td style="background-color: #000; border-radius: 6px;">
                  <a href="https://example.com"
                    style="display: inline-block; padding: 12px 24px;
                    font-family: Arial, sans-serif; font-size: 14px;
                    color: #ffffff; text-decoration: none;">
                    Get Started
                  </a>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Dark mode in Gmail

Gmail web leaves your email's colours alone when its interface goes dark; the iOS and Android apps recolour light backgrounds and dark text themselves. @media (prefers-color-scheme) does not apply anywhere in Gmail. What each app does and how to protect your colours and logo are in the dark mode email guide.

Gmail web vs the Gmail iOS and Android apps

Which CSS reaches the reader depends on the Gmail app and the account type:

  • Gmail Web, keeps a head style block (16KB cap) and supports media queries, flexbox and grid
  • Gmail Android, same as the web for Google accounts; inline styles only for other accounts
  • Gmail iOS, same account rule as Android

To style Gmail alone, Gmail web injects an empty <u></u> before your body class, so a u + .body rule in the kept <style> block applies in Gmail and not in Outlook. It does not replace inlining. The selector, its Android variant and the hacks that no longer match are in email client targeting CSS.

Questions

Does Gmail support external CSS stylesheets or @import?

No. <link> is not supported in Gmail. @import is not supported in Gmail. All CSS has to be inline or in a <style> block in the document head.

Why does Gmail rewrite my CSS classes?

Gmail isolates each email inside its own page by prefixing class names (with strings like m_ followed by an id) and rewriting the selectors in your <style> block to match, so ordinary class rules keep working. What breaks is a selector Gmail cannot rewrite, or a <style> block it discards for being in the <body> or over 16KB.

Does Gmail support CSS Flexbox and Grid?

The display values, yes: display:flex works in Gmail. display:grid works in Gmail. The properties that do the layout are another matter: flex-direction is not supported in Gmail. grid-template-columns is not supported in Gmail. In the Gmail apps, styles in the <style> block apply only for Google accounts. And display:flex is not supported in Outlook Classic. Tables (with role='presentation') remain the structure that reaches every reader.

Can I use web fonts like Google Fonts in Gmail?

@font-face is not supported in Gmail. External font links do not load either, so Gmail shows a system font. Always declare a system font stack such as font-family: Arial, Helvetica, sans-serif.

Your next question

Also useful: Gmail Clipping & Size Checker · CSS Inliner · Gmail CSS support

Paste the email that broke.

The checker needs a computer screen.

Get new email CSS fixes by email, or follow by RSS.