Many email clients don't like linked CSS stylesheets, or even the embedded <style>
tag, but rather want the CSS to appear inline as style attributes on all your markup.
- BAD:
<link rel=stylesheet type="text/css" href="/style.css">
- BAD:
<style type="text/css">...</style>
- WORKS:
<h1 style="margin: 0">...</h1>
However this inline style attribute approach is a right pain to manage.
I've found tools for Ruby and PHP that will take a CSS file and some separate markup as input and return you the merged result - a single file of markup with all the CSS converted to style attributes.
I'm looking for a Perl solution to this problem, but I've not found one on CPAN or by searching Google. Any pointers? Alternatively, are there CPAN modules one could combine to achieve the same result?
You can use
CSS::Inliner
http://search.cpan.org/dist/CSS-Inliner/I do not know of a complete, pre-packaged solution.
CSS::DOM's
compute_style
is subject to pretty much the same caveats as emogrifier above. That module, in conjunction with HTML::TokeParser ought to be usable to cook up something.Update: Here is a buggy mish-mash of things: