PHPackages                             tijsverkoyen/css-to-inline-styles - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. tijsverkoyen/css-to-inline-styles

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

tijsverkoyen/css-to-inline-styles
=================================

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.

v2.4.0(5mo ago)5.8k505.3M—4.6%194[24 issues](https://github.com/tijsverkoyen/CssToInlineStyles/issues)[9 PRs](https://github.com/tijsverkoyen/CssToInlineStyles/pulls)20BSD-3-ClausePHPPHP ^7.4 || ^8.0CI passing

Since Oct 13Pushed 4mo ago52 watchersCompare

[ Source](https://github.com/tijsverkoyen/CssToInlineStyles)[ Packagist](https://packagist.org/packages/tijsverkoyen/css-to-inline-styles)[ Docs](https://github.com/tijsverkoyen/CssToInlineStyles)[ RSS](/packages/tijsverkoyen-css-to-inline-styles/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (29)Used By (20)

CssToInlineStyles class
=======================

[](#csstoinlinestyles-class)

[![CI](https://github.com/tijsverkoyen/CssToInlineStyles/actions/workflows/ci.yml/badge.svg)](https://github.com/tijsverkoyen/CssToInlineStyles/actions/workflows/ci.yml)

About
-----

[](#about)

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.

Installation
------------

[](#installation)

The recommended installation way is through [Composer](https://getcomposer.org).

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

Example
-------

[](#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
------------

[](#known-issues)

- no support for pseudo selectors
- no support for [css-escapes](https://mathiasbynens.be/notes/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
----------------------

[](#sites-using-this-class)

- [Each site based on Fork CMS](http://www.fork-cms.com)
- [Print en Bind](http://www.printenbind.nl)
- [Tiki Wiki CMS Groupware](http://sourceforge.net/p/tikiwiki/code/49505) (starting in Tiki 13)
- [Laravel Framework](https://github.com/laravel/framework/blob/v6.18.24/src/Illuminate/Mail/Markdown.php#L55)

###  Health Score

76

—

ExcellentBetter than 100% of packages

Maintenance74

Regular maintenance activity

Popularity86

Widely adopted with strong download metrics

Community54

Growing community involvement

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 51.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~177 days

Recently: every ~294 days

Total

28

Last Release

167d ago

Major Versions

1.5.5 → 2.0.02016-02-23

PHP version history (6 changes)1.0.6PHP &gt;=5.2.0

1.2.0PHP &gt;=5.3.0

2.2.0PHP ^5.5 || ^7

2.2.1PHP ^5.5 || ^7.0

2.2.3PHP ^5.5 || ^7.0 || ^8.0

v2.3.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0afcdc0a47a32db64cc2e4c3b4cf59a5e283040d6e9f34284933394c24841f68?d=identicon)[tijsverkoyen](/maintainers/tijsverkoyen)

---

Top Contributors

[![tijsverkoyen](https://avatars.githubusercontent.com/u/250042?v=4)](https://github.com/tijsverkoyen "tijsverkoyen (153 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (74 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (23 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (8 commits)")[![driesvints](https://avatars.githubusercontent.com/u/594614?v=4)](https://github.com/driesvints "driesvints (5 commits)")[![jbboehr](https://avatars.githubusercontent.com/u/225601?v=4)](https://github.com/jbboehr "jbboehr (5 commits)")[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (4 commits)")[![Ugoku](https://avatars.githubusercontent.com/u/3470653?v=4)](https://github.com/Ugoku "Ugoku (2 commits)")[![Hikariii](https://avatars.githubusercontent.com/u/1484903?v=4)](https://github.com/Hikariii "Hikariii (2 commits)")[![BFTrick](https://avatars.githubusercontent.com/u/1065372?v=4)](https://github.com/BFTrick "BFTrick (1 commits)")[![jasonwain](https://avatars.githubusercontent.com/u/1015436?v=4)](https://github.com/jasonwain "jasonwain (1 commits)")[![fkupper](https://avatars.githubusercontent.com/u/10757561?v=4)](https://github.com/fkupper "fkupper (1 commits)")[![lifo101](https://avatars.githubusercontent.com/u/367337?v=4)](https://github.com/lifo101 "lifo101 (1 commits)")[![marclaporte](https://avatars.githubusercontent.com/u/1004261?v=4)](https://github.com/marclaporte "marclaporte (1 commits)")[![mdio](https://avatars.githubusercontent.com/u/8616698?v=4)](https://github.com/mdio "mdio (1 commits)")[![mhujer](https://avatars.githubusercontent.com/u/353372?v=4)](https://github.com/mhujer "mhujer (1 commits)")[![MrPunyapal](https://avatars.githubusercontent.com/u/53343069?v=4)](https://github.com/MrPunyapal "MrPunyapal (1 commits)")[![DavidPrevot](https://avatars.githubusercontent.com/u/3936728?v=4)](https://github.com/DavidPrevot "DavidPrevot (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![renanrodrigo](https://avatars.githubusercontent.com/u/15742644?v=4)](https://github.com/renanrodrigo "renanrodrigo (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tijsverkoyen-css-to-inline-styles/health.svg)

```
[![Health](https://phpackages.com/badges/tijsverkoyen-css-to-inline-styles/health.svg)](https://phpackages.com/packages/tijsverkoyen-css-to-inline-styles)
```

###  Alternatives

[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[inlinestyle/inlinestyle

Apply CSS stylesheets directly as inline styles to a HTML document

140635.8k8](/packages/inlinestyle-inlinestyle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
