CKEditor removing empty tags

Brenden Kehren asked on July 29, 2014 01:55

I've got a design that has a < span > wrapped in a < span > for a font feature to display an icon similar to how the Bootstrap uses <i class="icon-phone"></i> . The CKEditor strips the empty < span > out.

Isn't there a setting to correct this without having to use &nbsp; or some other hack?

<span><span class="fa fa-phone"></span>555-555-5555</span>

Correct Answer

Ondrej Sevcik answered on July 29, 2014 10:30

Hi, you could insert into CKEditor config.js file following line:

CKEDITOR.dtd.$removeEmpty['span'] = false;

It works for me.

4 votesVote for this answer Unmark Correct answer

Recent Answers


Andrew Huchko answered on April 27, 2017 13:03 (last edited on April 27, 2017 13:04)

Regard to documentation for creditor in config you can also enter that fro applying it for all tags: config.fillEmptyBlocks = false; // Prevent filler nodes in all empty blocks.

fillEmptyBlocks CKEditor

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.