Styling HTML email for Gmail

Dónal picture Dónal · Jan 29, 2012 · Viewed 116.3k times · Source

I'm generating a html email that uses an internal stylesheet, i.e.

<!doctype html>
<html>
<head>
  <style type="text/css">
    h2.foo {color: red}    
  </style>
</head>
<body>
 <h2 class="foo">Email content here</foo>
</body>
</html>

When viewed in Gmail it seems all the styles in the internal stylesheet are ignored. It seems Gmail ignores all styles other than inline rules, e.g.

 <h2 style="color: red">Email content here</foo>

Is this my only option for styling HTML emails when viewed with Gmail?

Answer

substate picture substate · Feb 3, 2012

Use inline styles for everything. This site will convert your classes to inline styles: http://premailer.dialect.ca/