Reputation: 47624
I'm looking for a tool which uses the CSS selectors within a stylesheet to generate the selected inline style.
E.g :
<head>
<style text="text/css">
a {
text-decoration: none;
}
#a, #b, #c
{
position: absolute;
}
#b
{
left: 50px;
}
</style>
</head>
<body>
<div id="a">
<p>
<a href="http://www.stackoverflow.com">SO</a>
</p>
</div>
<div id="b">
</div>
<div id="c">
</div>
</body>
will be :
<body>
<div id="a" style="position: absolute">
<p>
<a href="http://www.stackoverflow.com" style="text-decoration: none;">SO</a>
</p>
</div>
<div id="b" style="position: absolute; left: 50px;">
</div>
<div id="c" style="position: absolute">
</div>
</body>
Any ideas ?!
EDIT :
I want to do that to be able to 'style' email in most email client, especially for gmail, which doesn't support external or even internal stylesheet.
Upvotes: 1
Views: 144
Reputation: 20378
If you want to pass it through an API and do it automatically from within your application, check out http://premailer.dialect.ca.
It's a lot easier to use an API integrated into your app if you're developing one, since you don't have to generate the email contents and
If you're using ruby, the project is open sourced here so you can integrate it directly.
Or if you're using node.js, there's a wrapper that makes the API even easier to use: https://github.com/JedWatson/node-premailer
If you prefer to use a web form, MailChimp have a great tool here. Mailchimp have an API too if you've got an account.
Upvotes: 1