Simple library for filtering HTML using CSS selectors.


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
20Nov 10, 2017Jul 18, 2016Minified + gzip package size for @comandeer/css-filter in KB



Build Status Dependency Status devDependency Status

Library for filtering HTML with CSS selectors.


npm install @comandeer/css-filter [--save]


Include script in your site:

<script src="node_modules/@comandeer/css-filter/dist/css-filter.umd.js"></script>

Under window.cssFilter you will find our library with some fancy methods (see API docs for details).

The simplest way to use the library is to create filter using the factory:

const filter = cssFilter.default( 'i' );
const filtered = filter.filter( `<div>
        <i>Only i tag will be preserved</i>
</div>` );

console.log( filtered.innerHTML ); // <i>Only i tag will be preserved</i>

All valid CSS selectors could be used as a rule (however not all valid CSS selectors make sense as such rules…).


API docs are available at http://comandeer.github.io/css-filter

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.