PHPackages                             spazzmarticus/e-css-tractor - 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. spazzmarticus/e-css-tractor

ActiveLibrary

spazzmarticus/e-css-tractor
===========================

Extracts CSS from HTML (Style-Tags)

1.0.0(6y ago)1507MITPHPPHP ^7.2

Since Sep 15Pushed 6y ago2 watchersCompare

[ Source](https://github.com/SpazzMarticus/eCSStractor)[ Packagist](https://packagist.org/packages/spazzmarticus/e-css-tractor)[ RSS](/packages/spazzmarticus-e-css-tractor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

eCSStractor [![Build Status](https://camo.githubusercontent.com/4fb142460d7b6fe47f4bd133d6c4df49d86906042ebfff4eb12e15a47ec3ea53/68747470733a2f2f7472617669732d63692e6f72672f5370617a7a4d617274696375732f6543535374726163746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SpazzMarticus/eCSStractor)
======================================================================================================================================================================================================================================================================================================================

[](#ecsstractor-)

Extracts CSS from HTML ``-Tags

*(Also the lamest wordplay I could possibly come up with...)*

How
---

[](#how)

### Installation

[](#installation)

Install via [composer](https://getcomposer.org/)

`composer require spazzmarticus/e-css-tractor`

### Usage

[](#usage)

```
//Your HTML-Document with one or more -Tags
$html = 'p { color: blue; }...h1 { background-color: green; }';
$eCSStractor = new eCSStractor();
$css = $eCCStractor->extract($html);

header("Content-type: text/css");
echo $css;
```

```
p { color: blue; }
h1 { background-color: green; }
```

### Example

[](#example)

Check out the `example/` directory. The styles from `input.html` are extracted in `css.php` and used in `usage.html`.

What not
--------

[](#what-not)

This doesn't optimize the styles. [GIGO](https://en.wikipedia.org/wiki/Garbage_in,_garbage_out) ;)

Why
---

[](#why)

I built a tool to send newsletters with. The [editor](http://ckeditor.com/) for the newsletter-content had to be able to work with multiple templates (each containing unique styles). By extracting the styles from the templates I was able to dynamically change the template for a preview (outside the editor) and the styles in the editor accordingly.

Before sending the newsletter the styles are [written inline](http://templates.mailchimp.com/resources/email-client-css-support/) by [emogrifier](https://github.com/jjriv/emogrifier) so there was no need to change anyting.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~677 days

Total

3

Last Release

2545d ago

Major Versions

0.2.0 → 1.0.02019-05-31

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

1.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7671dde90009502e4cdb4576dba1a34d1db8aecd12a2eed1dbbf72b7d27a8e87?d=identicon)[SpazzMarticus](/maintainers/SpazzMarticus)

---

Top Contributors

[![SpazzMarticus](https://avatars.githubusercontent.com/u/5716457?v=4)](https://github.com/SpazzMarticus "SpazzMarticus (39 commits)")

---

Tags

cssextract-cssextractorhtmlcssstylesheetextract

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spazzmarticus-e-css-tractor/health.svg)

```
[![Health](https://phpackages.com/badges/spazzmarticus-e-css-tractor/health.svg)](https://phpackages.com/packages/spazzmarticus-e-css-tractor)
```

###  Alternatives

[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[wikimedia/less.php

PHP port of the LESS processor

12327.4M77](/packages/wikimedia-lessphp)

PHPackages © 2026

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