<p>Have you tried using the <code>allowedTags</code> attribute in your Redactor config?</p>

<pre><code>$('#redactor').redactor({
    allowedTags: ['div','p', 'h1', 'h2', 'pre']
});
</code></pre>

<p>You can read about that here:</p>

<p><a href="http://imperavi.com/redactor/docs/settings/clean/#setting-allowedTags" rel="nofollow">http://imperavi.com/redactor/docs/settings/clean/#setting-allowedTags</a></p>

CC BY-SA 3.0
2014-12-24T19:43:59.627Z
2014-12-24T19:43:59.627Z
Mark Busnelli Jr
<p>Add <code>replaceDivs: false</code> only once in your JSON config and do not forget <strong><em>the comma</em></strong> at the end of each settings row.</p>

CC BY-SA 3.0
2016-02-18T18:46:32.440Z
2016-02-18T18:46:32.440Z
tao
<p>For me adding <code>replaceDivs: false</code> in redactor config file fixed my issue on div tag removal.</p>

CC BY-SA 3.0
2015-09-01T17:09:33.700Z
2015-09-01T17:09:33.700Z
migmaker
<p>When i enter HTML into redactor below it will strip out the first closing div and the second opening div leaving one col-md-6.  It actually saves it as I have below but as soon as redactor is re-initialised it strips out the closing and opening tag in the middle again.  This means no one can ever go in an edit the content as it will be a single column again once saved. Current setup of redactor is below and I have unchecked the clean HTML.</p>

<pre><code>&lt;div class="row"&gt;
    &lt;div class="col-md-6"&gt;
        &lt;p&gt;One Col&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;
    &lt;p&gt;One Col&lt;/p&gt;
    &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>Redactor JSON config:</p>

<pre><code>{
        buttons: ['html','formatting','bold','italic','unorderedlist','orderedlist','link','image','video'],
        plugins: ['fullscreen'],
        toolbarFixedBox: true,
        replaceDivs: false
        replaceDivs: false,
        paragraphize: false,
        removeEmpty: ['strong', 'em', 'span', 'p']
    }
</code></pre>

<p>Any ideas how I can get it just to accept the HTML we enter without problems?</p>

CC BY-SA 3.0
2014-12-22T17:16:31.863Z
Hi Andy, this doesn't answer your question but is something to consider; having 'complex' markup like this in a Rich Text field may not be the best idea, it might be worth considering a Matrix field (depending on the context here): http://buildwithcraft.com/docs/matrix-fields or another Craft field that handles purely the content, and the column markup is defined in your templates.
Jamie Wade
CC BY-SA 3.0
2014-12-22T17:22:48.333Z
Thansk for responding Jamie but this is actually a matrix field :(  Its quite annoying!
Andy Lake
CC BY-SA 3.0
2014-12-22T18:22:38.247Z
You mean the RTE is inside of a Matrix field? What Jamie is suggesting is ditching the RTE altogether and solely use a Matrix field. You'll have much more control over the markup, then.
Brad Bell
<redactor>
HTML being stripped/replaced by redactor on initialising despite being saved correctly
# HTML being stripped/replaced by redactor on initialising despite being saved correctly

(Asked by: username_0 on 2014-12-22)

When i enter HTML into redactor below it will strip out the first closing div and the second opening div leaving one col-md-6.  It actually saves it as I have below but as soon as redactor is re-initialised it strips out the closing and opening tag in the middle again.  This means no one can ever go in an edit the content as it will be a single column again once saved. Current setup of redactor is below and I have unchecked the clean HTML.

    
        One Col
    
    
    One Col
    
    

Redactor JSON config:
{
        buttons: ['html','formatting','bold','italic','unorderedlist','orderedlist','link','image','video'],
        plugins: ['fullscreen'],
        toolbarFixedBox: true,
        replaceDivs: false
        replaceDivs: false,
        paragraphize: false,
        removeEmpty: ['strong', 'em', 'span', 'p']
    }

Any ideas how I can get it just to accept the HTML we enter without problems?

**Tags:** redactor
> **Comments:**
> **username_1**: Hi Andy, this doesn't answer your question but is something to consider; having 'complex' markup like this in a Rich Text field may not be the best idea, it might be worth considering a Matrix field (depending on the context here): http://buildwithcraft.com/docs/matrix-fields or another Craft field that handles purely the content, and the column markup is defined in your templates.  
> **username_0**: Thansk for responding Jamie but this is actually a matrix field :(  Its quite annoying!  
> **username_2**: You mean the RTE is inside of a Matrix field? What Jamie is suggesting is ditching the RTE altogether and solely use a Matrix field. You'll have much more control over the markup, then.  

---

## 3 answers

### Answer by username_3 on 2014-12-24. Score: 3

Have you tried using the allowedTags attribute in your Redactor config?
$('#redactor').redactor({
    allowedTags: ['div','p', 'h1', 'h2', 'pre']
});

You can read about that here:
http://imperavi.com/redactor/docs/settings/clean/#setting-allowedTags


---

### Answer by username_4 on 2016-02-18. Score: 3

Add `replaceDivs: false` only once in your JSON config and do not forget ***the comma*** at the end of each settings row.


---

### Answer by username_5 on 2015-09-01. Score: 2

For me adding `replaceDivs: false` in redactor config file fixed my issue on div tag removal.


---

