<p>If all your tables should use the same class or classes, you could use my <a href="https://github.com/mmikkel/RetconHTML-Craft" rel="nofollow">Retcon</a> plugin to add the classname(s) in Twig:</p>

<pre><code>{{ entry.body|retconAttr('table', {class: 'someclassname'}) }}
</code></pre>

<p>If different tables need different classes, this isn't a solution, though.</p>

CC BY-SA 3.0
2016-10-17T19:34:01.883Z
2016-10-17T22:12:00.317Z
2016-10-17T22:12:00.317Z
Mats Mikkel Rummelhoff
<p>I have a site (Craft 2.5.2754) and am trying to add a class to a table within Redactor. Even if I disable Clean up HTML and Purify HTML (which would rather not do) the style is getting stripped out on save.</p>

<p>I've had a look through the config/settings for Redactor and there is an 'allowedAttr' setting for earlier versions but seems to have been removed in Redactor II.</p>

<p>Any suggestions on stopping the class being stripped out, preferably without having to disable Clean up HTML and/or Purify HTML?</p>

<redactor><settings><table><classes>
Redactor settings: stripping out classes from table
# Redactor settings: stripping out classes from table

(Asked by: username_0 on 2016-10-17)

I have a site (Craft 2.5.2754) and am trying to add a class to a table within Redactor. Even if I disable Clean up HTML and Purify HTML (which would rather not do) the style is getting stripped out on save.

I've had a look through the config/settings for Redactor and there is an 'allowedAttr' setting for earlier versions but seems to have been removed in Redactor II.

Any suggestions on stopping the class being stripped out, preferably without having to disable Clean up HTML and/or Purify HTML?

**Tags:** redactor, settings, table, classes

---

## 1 answers

### Answer by username_1 on 2016-10-17. Score: 3

If all your tables should use the same class or classes, you could use my Retcon plugin to add the classname(s) in Twig:
{{ entry.body|retconAttr('table', {class: 'someclassname'}) }}

If different tables need different classes, this isn't a solution, though.


---

