Umbraco how to stop Rich Text Box to automatically add <p> tag in html

DevUsman picture DevUsman · Dec 13, 2013 · Viewed 7k times · Source

I am developing a website in umbraco, the problem is when i insert my html in rich text editor it automatically inserts "p" (Paragraph Tag) tag in the html which is destroying my design.Please help me, i am stuck here.

Thank you.

Answer

Carl Sargunar picture Carl Sargunar · Dec 17, 2013

How are you adding the page field onto your markup? Through a view or as a pagefield?

If you're adding it as a pagefield add the attribute stripParagraph="true"

If you're adding in a view then you could try

Html.Raw(library.RemoveParagraphTags(Model.bodyText.ToString()))

But that will only remove the first one

You could roll your own version of that method to remove all P tage, or try what's suggested here - http://scottsdevblog.com/2011/08/get-rid-of-those-pesky-p-tags-in-umbracos-tinymce-editor/