CKeditor adds many <p>&nbsp</p> tags for all new lines when editing as HTML source. I found a discussion:


But I don't understand, how to fix it. If anybody fixed this, please, tell me, what should I write in CKeditor config file.

  • The issue that you linked to explains a number of potential techniques for resolving this issue. You need to be mores specific about what exactly you have attempted to do based on that link and what the results were.
    – sheena_d
    Commented May 13, 2012 at 19:27
  • If you simply want to remove the empty paragraphs you can use the following module, drupal.org/project/emptyparagraphkiller.
    – Sam Becker
    Commented May 14, 2012 at 0:48
  • If you are inside a paragraph and want to add a line without a paragraph tag then do a shift+enter instead, it will add a <br/> instead of a new <p> Commented Jan 18, 2015 at 3:37
  • 1
    I have the same problem. The users that left answers don't seems to understand that this paragraph is not added while typing the enter key when in wysiwyg mode. The paragraph is added when passing from source code to wysiwyg. If I click "switch to plain text editor" and do nothing, when I get back to "rich text editor", the paragraphs are added. The problem appears when switching from source code mode to wysiwyg mode. Commented Dec 10, 2015 at 16:44

5 Answers 5


You need to set ckeditor configuration setting


to proper value

(1) The default creates a paragraph element each time the "enter" key is pressed:

config.enterMode = CKEDITOR.ENTER_P; // inserts <p></p>

(2) You can choose to create a "div" element instead of a paragraph:

config.enterMode = CKEDITOR.ENTER_DIV; // inserts <div></div>
  • The setting that you are looking for *

(3) If you prefer to not wrap the text in anything, you can choose to insert a line break tag:

config.enterMode = CKEDITOR.ENTER_BR; // inserts <br />

The application developer indicates that using the ENTER_BR setting is not recommended. http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.enterMode

There are three more settings that are somewhat related to this subject:


A complete list of the available configuration options can be found here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html


The answers on this question are correct, but they don't explain how to implement this in a Drupal-way:

If your ckeditor is printing this:


You indeed need to change the configuration of ckeditor to stop filling empty blocks: So config.fillEmptyBlocks = false; is correct, but you need to tell Ckeditor's implementation that in to Drupal.

You can do this by writing a hook_editor_js_settings_alter as follows:

 * Implements hook_editor_js_settings_alter().
function HOOK_editor_js_settings_alter(array &$settings) {
  // inspect which settings the editor currently has
  // kint($settings['editor']['formats']['basic_html']['editorSettings']);
  $settings['editor']['formats']['basic_html']['editorSettings']['fillEmptyBlocks'] = false;

This will force CKeditor to output instead:


Which means you could target and hide them with CSS as follows:

p:empty {
  display: none;
  • note that the hook works in module but not in theme
    – Matoeil
    Commented Sep 9, 2021 at 13:39

Most of the writers at my work use MS Word to write articles and then they paste it into the CKEditor WYSIWYG. If you install and enable the Ckeditor Paragraph Paste Fix module it will remove the the <p>&nbsp</p> in real time.


I believe you are talking about the "Enter mode" in CKEditor setting. You got <p> everytime you use "Enter". You can change the "Enter mode" from <p> to <br> with the following steps.

  1. go to "Configuration > CKEditor"
  2. edit a input format (if you use Full, edit the Full input format)
  3. under "Cleanup and Output" setting, change the "<p>" to "<br>" on "Enter mode".

In the "Advanced options" section of CKEditor profile add this:

config.fillEmptyBlocks = false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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