CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.
CssToInlineStyles is a class that enables you to convert HTML-pages/files into
HTML-pages/files with inline styles. This is very useful when you’re sending
emails.
The recommended installation way is through Composer.
$ composer require tijsverkoyen/css-to-inline-styles
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
// create instance
$cssToInlineStyles = new CssToInlineStyles();
$html = file_get_contents(__DIR__ . '/examples/sumo/index.htm');
$css = file_get_contents(__DIR__ . '/examples/sumo/style.css');
// output
echo $cssToInlineStyles->convert(
$html,
$css
);
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
. (Note: using <meta charset="UTF-8">
does NOT work!)