Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Kim Grandgagnage 63 posts 86 karma points
    Feb 07, 2011 @ 15:01
    Kim Grandgagnage

    Remove empty paragraph tags in tinymce

    When my customer uses a tinymce editor in the backend of Umbraco, sometime empty paragraph lines are generated like <p>&nbsp;</p>

    This results in the fact that there is a lot of white space on the page.

    Is there a way to automatically get rid of these empty paragraph tags when the node is saved?

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 07, 2011 @ 16:02
    bob baty-barr

    if you are using jquery in your site, you can use this in your doc.ready section...

  • Christer Josefsson 53 posts 81 karma points
    Feb 07, 2011 @ 21:50
    Christer Josefsson


    You should change settings for validElements in tinyMceConfig.config, look for #p in the file and change it to -p.

    This link will explain the different characters meaning.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 08, 2011 @ 06:10
    bob baty-barr

    hey, i have found that the P tags are not truly empty... they have a non-breaking space... so this code would actually kill the paragraph tags left stranded by the insert macro into RTE issue...

    $("p").each(function() {
    var $this = $(this);
    if ($this.html() === "&nbsp;") {
  • Luke Johnson 61 posts 80 karma points
    Jun 30, 2011 @ 16:41
    Luke Johnson

    A server-side solution is:


    <%  string[] tags ={"&nbsp;","<p>","</p>"};
    string str1 ="<p>&nbsp;</p>";
    foreach(var tag in tags)
    = str1.Replace(tag,"");



  • Hamish 95 posts 153 karma points
    Oct 26, 2011 @ 23:23

    I think the approach on the following page is better than using jQuery/javascript:

    My thoughts are that you should only be using jQuery/javascript to enhance the user experience and functionality. This can easily be resolved on the server side without having to bog down the users browser with extra javascript calls.

  • Bipin Kataria 25 posts 55 karma points
    Dec 27, 2014 @ 06:12
    Bipin Kataria

    You guys can easly do it using TinyMCE settings.

    1. Go to "tinyMceConfig.config" file under "config" folder.
    2. Search for or go to "<customConfig>" section.
    3. Add new line as: <config key="forced_root_block"></config>

    This will not generate <p> tag in CMS Editor. So, you can write your content as you like. :) If you want to change it to something else then change it accordingly. For e.g. If you want to use <div> tag then change it to: <config key="forced_root_block">div</config>


  • Thomas Hansen 164 posts 391 karma points
    Sep 28, 2017 @ 12:31
    Thomas Hansen

    7.7.1 - won't work ?

  • Vladimir Knobel 95 posts 170 karma points
    Jan 22, 2018 @ 10:45
    Vladimir Knobel

    It seems that you need to add

    <config key="forced_root_block">false</config> 

    for it to work.
    Leaving it empty doesn't work for me in 7.7.2.

Please Sign in or register to post replies

Write your reply to: