Home » CMS

TinyMCE: Fix the removing of empty DIVs

23 October 2009 3 Comments

TinyMCE is a great WYSIWYG editor, but sometimes there are cases where it removes HTML tags when you go into the “HTML Source” mode and switch back to the editor. This is very frustrating to end-users.

By default, TinyMCE will remove a lot of HTML tags including empty ones (such has having a DIV spacer), select options, certain styles, etc. To get around this, you will need to change the option “extended_valid_elements”, which is before the setup : function(ed) line. Note: This will allow your users to add in any kind of HTML tags they want. Replace the “extended_valid_elements” line with:

valid_elements : "*[*]",
extended_valid_elements : "*[*]",

This will fix the problem with TinyMCE removing tags from the HTML Source mode.

3 Comments »

  • Ashlie Webb said:

    RT @dragonal: TinyMCE: Fix the removing of empty DIVs http://t.co/wNXKnEa This is the only method I found reliable Cheers

  • Mike said:

    Most simple solution and 100% works:
    Add the following to the object:

    ..

    You’ll get this:
    .

    If you’ve more empty elements within the div (AddThis for example), you’ll get this:

    .

    Try it yourself. In most cases this will need no other modifications in your config. Just add it to your template or in the HTML ;-)

  • Mike said:

    Most simple solution and 100% works:
    Add the following to the object:


    .

    You’ll get this:

    If you’ve more empty elements within the div (AddThis for example), you’ll get this:

    .

    Try it yourself. In most cases this will need no other modifications in your config. Just add it to your template or in the HTML

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.

*