Support » Fixing WordPress » html editor adding </p> before </div>

  • Resolved d00dlz


    I’ve been using the WP html editor (I have the “use visual editor” checkbox unchecked in my users options) and it has been inserting unnecessary closing p elements directly before my correct closing div tags. My code won’t validate because of this.

    I read a few posts and tried deleting this: p/-div[*], from this line:

    $valid_elements =

    in the wp-includes/js/tinymce/tiny_mce_config.php file.

    It’s still adding the unnecessary closing p element.

    Not sure what to do next. Has anyone experienced this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • If you insert your own html tags/code – turn OFF completely the visual/wysiwyg and NEVER turn it on.

    The wysiwyg is for code illiterates who just type text. Decide where do you belong and act accordingly: you cannot have both.

    And if you use the “code” editor – do NOT hit enter twice before your divs. Hitting Enter 2x = paragraph.

    I did turn it off, though. Unless I missed a step in turning it off. I deselected the visual editor checkbox, like I said before. Is there some other way to turn it off?

    And there are absolutely no spaces around my divs. Should I “clump” the code together so it all runs together as one line? Would that help? It makes it harder for me to read, but I guess if it would work.

    Since you were talking about tinymce files… I didn’t notice that it was turned off. If it is turned off – leave the tinymce files alone.

    Any plugins turned on that may affect your output?

    Yes, it works when I put the divs on the same lines as the ps. Sorry I should have realized this earlier.

    Furthermore: fix your permalinks on the blog:
    and then give a direct link to a post that doesn’t keep the formatting.

    Okay, so far it works when I make sure the closing div comes directly after the closing p. Like this:

    <p>blah blah.</p></div>
    <p>blah blah.</p></div>

    I’ll post a direct link to a post if anything should go wrong again. Thanks for your help.

    The html editor interprets
    Enter x 1 = br
    Enter x 2 = p

    Right, I see now, thanks!



    There’s a great plugin which wraps code with a comment to prevent the code from being altered by the html editor. It’s at and works in 2.6.2.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘html editor adding </p> before </div>’ is closed to new replies.