PHPackages                             brick/html - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. brick/html

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

brick/html
==========

HTML 5 generation library

0.1.1(8y ago)42.4k↓50%42MITPHPPHP &gt;=7.1

Since Oct 6Pushed 2y ago1 watchersCompare

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

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

Brick\\Html
===========

[](#brickhtml)

[![](https://raw.githubusercontent.com/brick/brick/master/logo.png)](https://raw.githubusercontent.com/brick/brick/master/logo.png)

A very simple HTML 5 generation library.

[![Build Status](https://github.com/brick/html/workflows/CI/badge.svg)](https://github.com/brick/html/actions)[![Coverage Status](https://camo.githubusercontent.com/a6bde40bcbd61032699e53eea88205d88531705a4e8a9c22603c7060eb62151b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f627269636b2f68746d6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/brick/html?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/f12def34848215338fa2ca6c96e23a10aa09b8de764d17163cbe7d6d38c3a9c0/68747470733a2f2f706f7365722e707567782e6f72672f627269636b2f68746d6c2f762f737461626c65)](https://packagist.org/packages/brick/html)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](http://opensource.org/licenses/MIT)

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

[](#installation)

This library is installable via [Composer](https://getcomposer.org/):

```
composer require brick/html
```

Requirements
------------

[](#requirements)

This library requires PHP 7.1 or later.

Project status &amp; release process
------------------------------------

[](#project-status--release-process)

This library is still under development.

The current releases are numbered `0.x.y`. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), `y` is incremented.

**When a breaking change is introduced, a new `0.x` version cycle is always started.**

It is therefore safe to lock your project to a given release cycle, such as `0.1.*`.

If you need to upgrade to a newer release cycle, check the [release history](https://github.com/brick/html/releases) for a list of changes introduced by each further `0.x.0` version.

Introduction
------------

[](#introduction)

This library contains a single class, `Tag`, that represents an HTML tag. You construct a `Tag` using a tag name:

```
use Brick\Html\Tag;

$div = new Tag('div');
```

### Attributes

[](#attributes)

You can pass an optional associative array of attributes to the constructor:

```
$div = new Tag('div', [
    'id' => 'main',
    'class' => 'block',
]);
```

Or you can set attributes later:

```
$tag->setAttributes([
    'id' => 'main',
    'class' => 'block',
]);
```

Or:

```
$tag->setAttribute('id', 'main')
    ->setAttribute('class', 'block');
```

You can also remove attributes:

```
$tag->removeAttribute('id');
```

### Content

[](#content)

You can set the content of a `Tag`, provided that it's not a *void* tag such as ``, ``, etc. If you try to modify the content of a void tag, you'll get a `LogicException`.

You can set or append a plain text content:

```
$tag->setTextContent('Hello, world!');
$tag->appendTextContent("\nWhat's up?");
```

Or set/append a HTML content:

```
$tag->setHtmlContent('Hello, world!');
$tag->appendHtmlContent("What's up?");
```

You can also append another `Tag`:

```
$tag->append($otherTag);
```

You can remove the content of a `Tag`:

```
$tag->empty();
```

You can check if a `Tag` has an empty content:

```
$tag->isEmpty(); // boolean
```

### Rendering a tag

[](#rendering-a-tag)

You can render a tag by using its `render()` method, or just by casting it to string:

```
echo $tag; // will output something like: Hello, world!
```

### Encoding

[](#encoding)

All texts (attributes, content) are expected to be valid UTF-8.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.7% 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 ~0 days

Total

2

Last Release

3146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57189121968030f0770811b461cc92f9c19c08f5c4767292f2ede48b7277cfad?d=identicon)[BenMorel](/maintainers/BenMorel)

---

Top Contributors

[![BenMorel](https://avatars.githubusercontent.com/u/1952838?v=4)](https://github.com/BenMorel "BenMorel (42 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

htmlhtml-tagsphpbrickhtml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brick-html/health.svg)

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

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[ckeditor/ckeditor

JavaScript WYSIWYG web text editor.

5234.2M76](/packages/ckeditor-ckeditor)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21320.9M15](/packages/caxy-php-htmldiff)[yajra/laravel-datatables-html

Laravel DataTables HTML builder plugin

2899.6M48](/packages/yajra-laravel-datatables-html)

PHPackages © 2026

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