voku / css-to-inline-styles
Only a Fork of -> 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.
Installs: 203 143
Dependents: 2
Suggesters: 0
Security: 0
Stars: 19
Watchers: 7
Forks: 187
Open Issues: 1
Requires
- php: >=7.0.0
- ext-dom: *
- symfony/css-selector: ~3.0 || ~4.0 || ~5.0
- voku/simple_html_dom: ~4.7
Requires (Dev)
- phpunit/phpunit: ~6.0 || ~7.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- dev-master / 1.6.x-dev
- 1.6.37
- 1.6.36
- 1.6.35
- 1.6.34
- 1.6.33
- 1.6.32
- 1.6.31
- 1.6.30
- 1.6.29
- 1.6.28
- 1.6.27
- 1.6.26
- 1.6.25
- 1.6.24
- 1.6.23
- 1.6.22
- 1.6.21
- 1.6.20
- 1.6.19
- 1.6.18
- 1.6.17
- 1.6.16
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.6
- dev-whitesource/configure
- dev-analysis-z4gVaG
- dev-patch-5
This package is auto-updated.
Last update: 2024-12-04 05:41:47 UTC
README
CssToInlineStyles class
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.
About
PHP CssToInlineStyles is a class to convert HTML into HTML with inline styles.
Installation
The recommended installation way is through Composer.
$ composer require voku/css-to-inline-styles
Example
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/');
Documentation
The following properties exists and have set methods available:
Warning
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);
Known issues
- no support for pseudo selectors