Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling HTML email for Gmail

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?

like image 765
Dónal Avatar asked Jan 29 '12 19:01

Dónal


People also ask

Can I put HTML code in Gmail?

To embed HTML in an email in Gmail, copy the code in a plain text format and render the code in a web browser first. Opening the HTML file in Chrome or another browser is just fine. This will display the email as it will appear in Gmail. Copy everything from the web browser display and paste directly into Gmail.


1 Answers

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

like image 169
substate Avatar answered Oct 10 '22 10:10

substate