CssToInlineStyles

by tijsverkoyen

tijsverkoyen / CssToInlineStyles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with...

5.3K Stars 172 Forks Last release: 4 months ago (2.2.3) BSD 3-Clause "New" or "Revised" License 249 Commits 28 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

CssToInlineStyles class

Build Status Scrutinizer Code Quality Code Coverage SensioLabsInsight

Installation

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.

About

PHP CssToInlineStyles is a class to convert HTML into HTML with inline styles.

Installation

The recommended installation way is through Composer.

$ composer require tijsverkoyen/css-to-inline-styles

Example

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 );

Known issues

  • no support for pseudo selectors
  • no support for css-escapes
  • UTF-8 charset is not always detected correctly. Make sure you set the charset to UTF-8 using the following meta-tag in the head:
    . (Note: using 
     does NOT work!)

Sites using this class

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.