What tools to automatically inline CSS style to create email HTML code? [closed]

帅比萌擦擦* 提交于 2019-11-25 23:31:26
Saleh Al-Zaid

Check the premailer.dialect.ca online converter or this Python script to do it.

Here is a list of web based ready to use inlining tools, a couple have been mentioned previously. If there are any I've missed, feel free to edit and add them. I can't promise each works as advertised, so drop comments, but don't shoot the messenger...

And here is one that works in reverse (un-inlining your css)

If you'd like to have a PHP solution, you can try CssToInlineStyles.

Two C# variants:

http://chrispebble.com/Blog/7/inlining-a-css-stylesheet-with-c

PreMailer.Net - https://github.com/milkshakesoftware/PreMailer.Net

Haven't tested either as of yet but will post back if/when I do.

You might want to take a look at PostageApp.

One of its really strong features is that it has a very robust templating system that can automatically inline HTML and CSS without any issues.

(Full Disclosure: I am the Product Manager for PostageApp.)

I wrote a Node.js library called Styliner that inlines CSS in server-side Javascript.

It supports LESS stylesheets as well (and supports plugins for other formats)

This may be a little too late, but if you want to make your HTML the best possible for e-mail marketing (by inlining your css, and using a bunch of other cool tools), use the Premailer. Its free, and of course, made in partnership with CampaignMonitor itself.

Hope it helps.

It's not enough to simply inline your CSS. There are no observed standards as to how an HTML email will be shown in whatever email client is used. They all do it differently, and the more you design your email the more likely it is that it will break in a greater amount of clients. Many professionals in this space simply use images and tables and maybe some background colors, but nothing else. Always include a link to a website that has a working copy of the email and always provide a plain text variant.

I'm a little late to the game but hopefully this will help someone.

I found this nice little jQuery/javascript method that can be embedded into a page - http://devintorr.es/blog/2010/05/26/turn-css-rules-into-inline-style-attributes-using-jquery/

I've edited it a little to support IE and also to support a page with multiple CSS files attached applying styles in the correct order.

$(document).ready(function ($) {
            var rules;
            for(var i = document.styleSheets.length - 1; i >= 0; i--){
                if(document.styleSheets[i].cssRules)
                    rules = document.styleSheets[i].cssRules;
                else if(document.styleSheets[i].rules)
                    rules = document.styleSheets[i].rules;
                for (var idx = 0, len = rules.length; idx < len; idx++) {
                    if(rules[idx].selectorText.indexOf("hover") == -1) {
                        $(rules[idx].selectorText).each(function (i, elem) {
                            elem.style.cssText = rules[idx].style.cssText + elem.style.cssText;
                        });
                    }
                }
            }
            $('style').remove();
            $('script').remove();
            $('link').remove();
        });

The page can then be copy/pasted into the email body.

EpokK

Another one from mailchimp - http://beaker.mailchimp.com/inline-css

For PHP programmers: check this online converter or this PHP script to do it.

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