Er Parveen Saini
Er Parveen Saini

Reputation: 95

Preventing CKEditor from adding <p> tags to content

I am using CKEditor for my HTML page. After loading the page I click on the div and make it editable. But the problem is that it automatically adds some p tags and some another tags.

Eg before click

<div style="width:100%;" class="homeHead editor ">
<i>My content.</i>
</div>

but after click

<div contenteditable="true" style="width: 100%; position: relative;" class="homeHead editor cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor1" title="Rich Text Editor, editor1" aria-describedby="cke_53">
<p><em>Affordable. Simple.</em></p>
</div>

how can i maintain my previous HTML

Upvotes: 1

Views: 4444

Answers (2)

Mari Selvan
Mari Selvan

Reputation: 3802

This one is helpful to solve Your Problem

 CKEDITOR.editorConfig = function( config )
 {
   config.enterMode = CKEDITOR.ENTER_BR;
 };

The "config.enterMode = CKEDITOR.ENTER_BR" will be Changed "p" tag into "br" tag.

Upvotes: 1

Soudip Paul
Soudip Paul

Reputation: 21

Put "CKEDITOR.config.enterMode" and "config.allowedContent" inside your config.js file as follows -

CKEDITOR.editorConfig = function( config ) {
    CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
    config.allowedContent = true;
};

Upvotes: 2

Related Questions