PHPackages                             codeat3/inlinestyle - 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. codeat3/inlinestyle

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

codeat3/inlinestyle
===================

Apply CSS stylesheets directly as inline styles to a HTML document

2.1.0(2y ago)073.9k↑507.4%1MITPHPPHP ^7.4|^8.0

Since Sep 10Pushed 2y agoCompare

[ Source](https://github.com/codeat3/inlinestyle)[ Packagist](https://packagist.org/packages/codeat3/inlinestyle)[ RSS](/packages/codeat3-inlinestyle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (2)Versions (16)Used By (1)

InlineStyle
===========

[](#inlinestyle)

[ ![Tests](https://github.com/codeat3/inlinestyle/workflows/Tests/badge.svg)](https://github.com/codeat3/inlinestyle/actions?query=workflow%3ATests)[ ![Scrutinizer Quality Score](https://camo.githubusercontent.com/34aee80388ed9cd9f8a94e1669bafc5432c2f4e939e48f2ab2a07bbe91502408/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6368726973746961616e2f496e6c696e655374796c652f6261646765732f7175616c6974792d73636f72652e706e673f733d66373331653739326662326561613330356532393461316132393238653962633936646361313262)](https://scrutinizer-ci.com/g/codeatt/InlineStyle/)[ ![Latest Stable Version](https://camo.githubusercontent.com/72964fac3e794194605f3909cfdf7481530a9603eef80dd27c9defedd20f3441/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64656174332f696e6c696e657374796c65)](https://packagist.org/packages/codeat3/inlinestyle)[ ![Total Downloads](https://camo.githubusercontent.com/09f3b5ec037c882d551fbfd7af92d062ce3faf81479cd4a572ee78a38f576e41/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64656174332f696e6c696e657374796c65)](https://packagist.org/packages/codeat3/inlinestyle)This is a fork of the original repository (christiaan/InlineStyle)\[\] by [Christiaan Baartse ](https://github.com/christiaan)

InlineStyle provides an easy way to apply embedded and external stylesheets directly as inline styles on the HTML tags. This is especially targetted at mail clients which mostly dont support stylesheets but do support the style attribute for HTML tags.

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

[](#installation)

```
composer require inlinestyle/inlinestyle

```

Or add the following to your composer.json file

```
"require": {
    "inlinestyle/inlinestyle": "^2.0"
}

```

Usage
-----

[](#usage)

---

Use composer to download required dependencies.

Import InlineStyle

```
use \InlineStyle\InlineStyle;

```

Create a new InlineStyle object from either a HTML string or HTML file.

```
$htmldoc = new InlineStyle("testfiles/test.html");

```

or

```
$htmldoc = new InlineStyle(file_get_contents("http://github.com"));

```

### Apply the embedded and external stylesheets

[](#apply-the-embedded-and-external-stylesheets)

---

First we'll have to extract the stylesheets from the document and then we have to apply them.

```
$htmldoc->applyStylesheet($htmldoc->extractStylesheets());

```

The second param is the base url that is used to parse the links to external stylesheets.

```
$htmldoc->applyStylesheet($htmldoc->extractStylesheets(null, "http://github.com"));

```

### Applying additional stylesheets

[](#applying-additional-stylesheets)

This class can also be used to apply a given css template to each processed HTML file.

```
$htmldoc->applyStylesheet(file_get_contents("testfiles/external.css"));

```

### Retrieving the modified HTML

[](#retrieving-the-modified-html)

After calling applyStylesheet various times the resulting HTML can be retrieved as a string using getHTML.

```
$html = $htmldoc->getHTML();

```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 50.8% 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 ~348 days

Recently: every ~750 days

Total

13

Last Release

857d ago

Major Versions

1.2.8 → 2.02022-02-03

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

2.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/166912?v=4)[Swapnil Sarwe](/maintainers/swapnilsarwe)[@swapnilsarwe](https://github.com/swapnilsarwe)

---

Top Contributors

[![christiaan](https://avatars.githubusercontent.com/u/118490?v=4)](https://github.com/christiaan "christiaan (33 commits)")[![mtibben](https://avatars.githubusercontent.com/u/980499?v=4)](https://github.com/mtibben "mtibben (12 commits)")[![swapnilsarwe](https://avatars.githubusercontent.com/u/166912?v=4)](https://github.com/swapnilsarwe "swapnilsarwe (7 commits)")[![madleech](https://avatars.githubusercontent.com/u/1756799?v=4)](https://github.com/madleech "madleech (4 commits)")[![leith](https://avatars.githubusercontent.com/u/647389?v=4)](https://github.com/leith "leith (3 commits)")[![neilime](https://avatars.githubusercontent.com/u/314088?v=4)](https://github.com/neilime "neilime (2 commits)")[![thomasbachem](https://avatars.githubusercontent.com/u/231538?v=4)](https://github.com/thomasbachem "thomasbachem (1 commits)")[![j13k](https://avatars.githubusercontent.com/u/1084378?v=4)](https://github.com/j13k "j13k (1 commits)")[![rskuipers](https://avatars.githubusercontent.com/u/1918518?v=4)](https://github.com/rskuipers "rskuipers (1 commits)")[![0b10011](https://avatars.githubusercontent.com/u/1123348?v=4)](https://github.com/0b10011 "0b10011 (1 commits)")

---

Tags

cssemailinline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codeat3-inlinestyle/health.svg)

```
[![Health](https://phpackages.com/badges/codeat3-inlinestyle/health.svg)](https://phpackages.com/packages/codeat3-inlinestyle)
```

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.7k734.8M443](/packages/egulias-email-validator)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94746.7M138](/packages/pelago-emogrifier)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[inlinestyle/inlinestyle

Apply CSS stylesheets directly as inline styles to a HTML document

144658.7k13](/packages/inlinestyle-inlinestyle)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.6k50.9M190](/packages/sendgrid-sendgrid)[zbateson/mail-mime-parser

MIME email message parser

54753.3M91](/packages/zbateson-mail-mime-parser)

PHPackages © 2026

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