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

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

inlinestyle/inlinestyle
=======================

Apply CSS stylesheets directly as inline styles to a HTML document

1.2.7(10y ago)140635.8k↓29.9%25[7 issues](https://github.com/christiaan/InlineStyle/issues)[1 PRs](https://github.com/christiaan/InlineStyle/pulls)7MITPHPPHP &gt;=5.3.3CI failing

Since Sep 10Pushed 2y ago12 watchersCompare

[ Source](https://github.com/christiaan/InlineStyle)[ Packagist](https://packagist.org/packages/inlinestyle/inlinestyle)[ RSS](/packages/inlinestyle-inlinestyle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (12)Used By (7)

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

[](#inlinestyle)

[![Build Status](https://camo.githubusercontent.com/49377a6251ed4dbc938275040e8981a788a10f812054770607a5483849794892/68747470733a2f2f7472617669732d63692e6f72672f6368726973746961616e2f496e6c696e655374796c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/christiaan/InlineStyle)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/34aee80388ed9cd9f8a94e1669bafc5432c2f4e939e48f2ab2a07bbe91502408/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6368726973746961616e2f496e6c696e655374796c652f6261646765732f7175616c6974792d73636f72652e706e673f733d66373331653739326662326561613330356532393461316132393238653962633936646361313262)](https://scrutinizer-ci.com/g/christiaan/InlineStyle/)

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)

Run composer.phar require inlinestyle/inlinestyle Or add the following to your composer.json file "require": { "inlinestyle/inlinestyle": "1.\*" }

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

45

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 56.9% 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 ~132 days

Recently: every ~171 days

Total

10

Last Release

3809d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8571758471c73669aeb7e688a77b6cf5de0c6b2a99bb7ee12888d4b793bfd27f?d=identicon)[christiaan](/maintainers/christiaan)

---

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)")[![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/inlinestyle-inlinestyle/health.svg)

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

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[sendgrid/sendgrid

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

1.5k47.5M164](/packages/sendgrid-sendgrid)[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48519.5M75](/packages/soundasleep-html2text)[robertotru/to-inline-style-email-bundle

A Symfony2 bundle for using the CssToInlineStyles translator by tijsverkoyen

59384.3k](/packages/robertotru-to-inline-style-email-bundle)

PHPackages © 2026

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