Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I have a problem when trying to put a div into a content of an entry.

I'm creating entries, building a HTML hierarchy that helps me to manipulate the content with JS. I'm adding divs an build something like this:

<div id="cont1" class="content" >
  <h3>Hi I am a title</h3>
  <p>this is the introduction </p>
  <p>this is the content</p>
</div>

When I create this, the hierarchy is right, but when I edit it from the CP, all the divs change to this:

<p id="cont1" class="content" ></p>
<h3>Hi I am a title</h3>
<p>this is the introduction </p>
<p>this is the content</p>

What can I do to prevent this from happening? Hope you can help me, thanks.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Assuming you are using the Rich Text field, you'll want to look at the Redactor setting, convertDivs.

convertDivs (Default setting is true)

With this option turned on, Redactor will automatically replace divs to paragraphs.

Go in to your field settings: Craft Admin › Settings › Fields › Rich Text field name

Look at the config settings to determine which config file you are using. Then, go in to your craft/config/redactor/ConfigFile.json file and edit your redactor settings to exclude the convertDivs setting (assuming nothing else in your config file):

{
    convertDivs: false
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.