| Recommend this page to a friend! | 
| Info | Example | Reputation | Support forum | Blog | Links | 
| Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
| 2025-05-07 (1 month ago)  | Total: 380 | All time:  6,734 This week: 89 | ||||||
| Version | License | PHP version | Categories | |||
| csstoinlinestyles 1.6.38 | BSD License | 5.3 | HTML, PHP 5, Parsers | 
| Description | Authors Tijs Verkoyen Contributor  | |
This package can convert CSS styles into HTML attribute values, Innovation Award  | 
<?php | 
WARNING: this is only a Extended-Fork of "https://github.com/tijsverkoyen/CssToInlineStyles"
> 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.
PHP CssToInlineStyles is a class to convert HTML into HTML with inline styles.
The recommended installation way is through Composer.
$ composer require voku/css-to-inline-styles
use voku\CssToInlineStyles\CssToInlineStyles;
// Convert HTML + CSS to HTML with inlined CSS
$cssToInlineStyles= new CssToInlineStyles();
$cssToInlineStyles->setHTML($html);
$cssToInlineStyles->setCSS($css);
$html = $cssToInlineStyles->convert();
// Or use inline-styles blocks from the HTML as CSS
$cssToInlineStyles = new CssToInlineStyles($html);
$cssToInlineStyles->setUseInlineStylesBlock(true);
$html = $cssToInlineStyles->convert();
// Or use linked files from the HTML as CSS
$cssToInlineStyles = new CssToInlineStyles($html);
$cssToInlineStyles->setLoadCSSFromHTML(true);
$html = $cssToInlineStyles->convert(false, 0, __DIR__ . '/../tests/');
The following properties exists and have set methods available:
Property | Default | Description -------|---------|------------ cleanup|false|Should the generated HTML be cleaned? useInlineStylesBlock |false|Use inline-styles block as CSS. stripOriginalStyleTags |false|Strip original style tags. excludeMediaQueries |true|Exclude media queries from extra "css" and keep media queries for inline-styles blocks. excludeConditionalInlineStylesBlock |true|Exclude conditional inline-style blocks.
Also if the default is `cleanup === false`, you maybe need to use this feature, because Outlook has some special features where the inline-CSS will be ignored and it will fallback to use only the CSS-Class- or ID-properties.
$cssToInlineStyles->setCleanup(true);
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Example | Example script | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Doc. | Documentation | |||
| / | example | 
| File | Role | Description | ||
|---|---|---|---|---|
|    | 
Aux. | Auxiliary script | ||
|    | 
Example | Example script | ||
| / | example | / | examples | / | sumo | 
| / | src | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| / | tests | 
| File | Role | Description | ||
|---|---|---|---|---|
|    | 
Aux. | Auxiliary script | ||
|    | 
Class | Class source | ||
|    | 
Class | Class source | ||
| / | tests | / | fixtures | 
| File | Role | Description | 
|---|---|---|
|    | 
Data | Auxiliary data | 
|    | 
Data | Auxiliary data | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Data | Auxiliary data | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Data | Auxiliary data | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
|    | 
Doc. | Documentation | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| csstoinlinestyles-2025-05-07.zip 95KB | |
| csstoinlinestyles-2025-05-07.tar.gz 68KB | |
| Install with Composer | 
| Needed packages | ||
| Class | Download | Why it is needed | Dependency | 
|---|---|---|---|
| Simple HTML DOM | Dom-Manipulation | Required | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| User Ratings | User Comments (1) | ||||||||||||||||||||||||||||||||||
  | 
  | ||||||||||||||||||||||||||||||||||
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.