CSS on Email

雨燕双飞 提交于 2019-12-03 13:58:19

The only way we've been successful is to include the CSS inline. Document Header style CSS inclusion isn't consistent or reliable.

Also, make sure your email headers are set to: Content-type: text/html; charset=ISO-8859-1

EDIT UTF-8 is also a good option. The KEY point of that statement is the Content-type being set to text/html

Here is a comprehensive guide on which css styles are supported by each email client: http://www.campaignmonitor.com/css/

A guide on what you will need to know: http://www.campaignmonitor.com/design-guidelines/

There is also a large collection of free pre-built templates that you can use as a reference: http://www.campaignmonitor.com/templates/

Finally, the same company provides a testing tool that will show you how your message will show up in each email client for a reasonable fee: http://www.campaignmonitor.com/testing/

You unfortunately need to include the CSS inline in the elements to have any vague compatibility across email clients. In addition you should use tables for layout (columns, etc) because CSS div layouts often fail. Attached images also fail mostly for cid: URLs. Thunderbird is about the best mail client for compatibility (obviously, as it uses the Gecko renderer). Outlook is the worst.

In addition use multipart mime with a plain text alternative. I use a database to store email templates, and there are plain text and html templates, with {{replaceable}} values.

Inline CSS is a must to ensure maximum compatibility.

Some systems like MailChimp will take your element classes, parse your CSS, and replace the class attributes with inline styles. You could write your own code to do this.

In addition to the inline css that everyone is recommending, keep in mind that email is often displayed online within another web page, such as through Yahoo! Mail, Hotmail, or Gmail. You can imagine the chaos that would ensue if body style declarations or random class names were allowed. You should plan for the possibility that anything that is not defined inline will be discarded, although some systems might attempt to preserve these rules with unpredictable success.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!