Htmlpurifier remove inline css

I am using htmlpurifier to clear user content. I am trying to remove inline style attributes like

<div style="float:left">some text</div> 

I want to remove the entire style attribute.

How to do this with htmlpurifier?

+6
source share
1 answer

You can customize AllowedProperties by passing it an array of valid CSS attributes that should not be removed (whitelist approach).

However, the following should remove all css attributes

 $config->set('CSS.AllowedProperties', array()); 

Watch this online demo of cleaning your html file

+17
source

Source: https://habr.com/ru/post/906112/


All Articles