Turn off enclosing <p> tags in CKEditor 3.0

Kosi2801 picture Kosi2801 · Dec 30, 2009 · Viewed 105.8k times · Source

Is there a possibility to turn off the automatic enclosing of all written content within <p></p> in CKEditor 3.x?

I tried

  CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;

but this just changes the inline linebreaks to <br /> while leaving the enclosing paragraph.

Currently writing "Test" produces this output

<p>
    Test</p>

but I want it to be simply

Test

Is there a configuration property for this or would another inline editor to be better suited for this?

Answer

Maksymilian Majer picture Maksymilian Majer · Apr 21, 2010

CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; - this works perfectly for me. Have you tried clearing your browser cache - this is an issue sometimes.
You can also check it out with the jQuery adapter:

<script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/js/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(function() {
    $('#your_textarea').ckeditor({
        toolbar: 'Full',
        enterMode : CKEDITOR.ENTER_BR,
        shiftEnterMode: CKEDITOR.ENTER_P
    });
});
</script>


UPDATE according to @Tomkay's comment:

Since version 3.6 of CKEditor you can configure if you want inline content to be automatically wrapped with tags like <p></p>. This is the correct setting:

CKEDITOR.config.autoParagraph = false;

Source: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.autoParagraph