PHPackages                             ivopetkov/html5-dom-document-php - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ivopetkov/html5-dom-document-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ivopetkov/html5-dom-document-php
================================

HTML5 DOMDocument PHP library (extends DOMDocument)

v2.10.1(3mo ago)6031.4M↓12.4%43[8 issues](https://github.com/ivopetkov/html5-dom-document-php/issues)20MITPHPPHP 8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*|8.5.\*CI failing

Since Mar 30Pushed 3mo ago28 watchersCompare

[ Source](https://github.com/ivopetkov/html5-dom-document-php)[ Packagist](https://packagist.org/packages/ivopetkov/html5-dom-document-php)[ Fund](https://www.paypal.me/ivopetkovcom)[ GitHub Sponsors](https://github.com/ivopetkov)[ RSS](/packages/ivopetkov-html5-dom-document-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (73)Used By (20)

HTML5DOMDocument
================

[](#html5domdocument)

HTML5DOMDocument extends the native [DOMDocument](http://php.net/manual/en/class.domdocument.php) library. It fixes some bugs and adds some new functionality.

[![Latest Stable Version](https://camo.githubusercontent.com/0d12b11527d3c212a0dd9ec137c4abb78f8ae2b2f93abbe76f2b4daa608238ed/68747470733a2f2f706f7365722e707567782e6f72672f69766f7065746b6f762f68746d6c352d646f6d2d646f63756d656e742d7068702f762f737461626c65)](https://packagist.org/packages/ivopetkov/html5-dom-document-php)[![License](https://camo.githubusercontent.com/56364e0da53b810e1239bc8640dfb121ffd384d244dffe76b1cb7c700afcc7dd/68747470733a2f2f706f7365722e707567782e6f72672f69766f7065746b6f762f68746d6c352d646f6d2d646f63756d656e742d7068702f6c6963656e7365)](https://packagist.org/packages/ivopetkov/html5-dom-document-php)

Why use?
--------

[](#why-use)

- Preserves html entities (DOMDocument does not)
- Preserves void tags (DOMDocument does not)
- Allows **inserting HTML code** that moves the correct parts to their proper places (head elements are inserted in the head, body elements in the body)
- Allows **querying the DOM with CSS selectors** (currently available: \*, tagname, tagname#id, #id, tagname.classname, .classname, tagname.classname.classname2, .classname.classname2, tagname\[attribute-selector\], \[attribute-selector\], "div, p", div p, div &gt; p, div + p and p ~ ul.)
- Adds support for element-&gt;classList.
- Adds support for element-&gt;innerHTML.
- Adds support for element-&gt;outerHTML.

Install via Composer
--------------------

[](#install-via-composer)

```
composer require "ivopetkov/html5-dom-document-php:2.*"
```

Documentation
-------------

[](#documentation)

Full [documentation](https://github.com/ivopetkov/html5-dom-document-php/blob/master/docs/markdown/index.md) is available as part of this repository.

Examples
--------

[](#examples)

Use just like you should use DOMDocument:

```
