Search code examples
javascriptjquerytinymcetinymce-4

Need to have both p tag and br tag in tinyMCE editor


In tinyMCE editor, I need to have both p tag and br tag, which means p tag should wrap the br tag. While inspecting P tag wraps the BR tag <p><br></p> but in the code block of tinyMCE editor, it shows only p block, tried with valid_elements:'*[*]', not working.

added br tag in the DOM

Without br tag


Solution

  • Found this answer by myself via CSS, not in TinyMCE editor, We can add some height to the p tag if it is empty

    p:empty{
    height:5px;
    }
    

    to add space, if the br tag is not appending,

    Found what the issue actually, When I removed the configuration valid element: '*[*]' , It works fine with <p>&nbsp;</p>