I have been working on a Sitecore 9 migration project. The client told us to use the existing html and stylesheets and use SXA as much as possible.

We have used RichText control in a few places but when the content author does any changes in the experience editor, the html gets removed.


enter image description here

<div class="media"> <a class="pull-left" href="#">
<img class="media-object" data-src="holder.js/64x64"></a>
    <div class="media-body">
        <h4 class="media-heading">Media heading</h4>
        <div class="content" Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.></div>

Content author => open experience editor and changes the h4 title completely. It removes the html (h4 along with class).

How can we prevent that the html gets removed when the content author edits in the RTE? Is there any settings available for rich text editor in Sitecore?

3 Answers 3


The short answer is - you can't. By design, even if you disable the Edit HTML tab in the RTE, just by editing the text, the editor will modify the html contained within.

Your component is designed wrong for this use case. If you want full control over the markup, then you should use a rendering that holds the markup in a razor view and then renders fields to the correct place. In your example, I would create Title and Body Content fields. Then use whatever ORM/Wrapper/Sitecore API tooling you are using to render the contents of those fields to the required places.

Especially as you are using SXA. You could easily create a new rendering variant that built up your component to match that markup very closely.

The only other way, would be to modify the contents of the Rich Text when the item is saved, to put back any html that was removed. But that would require a lot of HTML parsing, which isn't simple (and no - regex is not the answer ;) ). It would take less time and cause less bugs to just redesign the components correctly.


I have encountered this on other CMS, and the shortest and smartest solution without modifying anything is, when you are done with your edits, switch back to design mode to check the changes and then SAVE it. You will not lose anything.

enter image description here

Another thing that can be done is, while you are still on design mode, you can select the specific tag and click on the available tag references and select your desired one, and SAVE.

enter image description here


You can restrict the user to use the "Edit HTML" in RTE.

  1. Go to the core database, locate the field definition item: /sitecore/system/Field types/Simple Types/Rich Text/Menu/Edit Html
  2. On the Security Tab, click “Assign” and select the role "Content Author" fpr whom you don’t want this option to be available to. Deny inheritance of this item or specify other security settings that make sense for your needs.

You can get more details here: http://sitecoreblog.alexshyba.com/2009/10/quick-tip-remove-edit-html-option-for.html

  • 1
    This doesn't solve the problem. The html can still be changed just in the rich text editor. All the user would have to do is select the text for the h4 tag and change the style or delete it and the markup will get removed.
    – Richard Seal
    Mar 19, 2018 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.