Custom rich text editor styles for Content editor web part

I received a request from business to restrict site editor not to use OOTB fonts and styles while they edit the contents of “Content editor web part” in SharePoint 2010. This is nice to have if you want consistent look and feel across the site without much end end-user training. 

They asked me to create custom styles; apart from those styles the editor should not be able to apply any font, colours or styles on CEWP contents.

I have done these changes on “Page Layout”. If an editor creates any page using that page layout, he/she will only see custom styles while editing the “content editor web part” contents.

Below are the detailed steps to achieve this kind of functionality

(Change the below CustomRTStyles.css style sheet according to your requirement)

/* Custom rich text editor Styles list */


{-ms-name:"Heading 1";



 font-family:"Gill Sans MT";



{-ms-name:"Heading 2";



 font-family:"Gill Sans MT";



{-ms-name:"Heading 3";



 font-family:"Gill Sans MT";



{-ms-name:"Heading 4";



 font-family:"Gill Sans MT";






 font-family:"Arial, Helvetica, sans-serif" }


{-ms-name:"Intro Paragraph";



 font-family:"Arial, Helvetica, sans-serif"}

/* To hide fonts tab */


{  display:none;} 

/* To hide Markup styles tab */


<link rel="stylesheet" type="text/css" href=" /Style%20Library/en-us/Core%20Styles/CustomRTStyles.css" />

Now save and publish the master page.

PrefixStyleSheet=”custom-rte” AllowFonts=”false”

The < RichHtmlField > control with look like the following

<PublishingWebControls:RichHtmlField FieldName="PublishingPageContent"  HasInitialFocus="True" PrefixStyleSheet="custom-rte" AllowFonts="false" MinimumEditHeight="400px" runat="server"/>

Reference custom css inside page layout just before the <PublishingWebControls:EditModePanel> control 

<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/CustomRTStyles.css %>" runat="server"/>
<PublishingWebControls:EditModePanel runat="server">

<!-- Styles for edit mode only-->

<script src="" type="text/javascript"></script>

<script type="text/javascript">

ExecuteOrDelayUntilScriptLoaded(function() {

 // window.setTimeout(function() {

 $("div[RteRedirect]").each(function() {

var id = $(this).attr("RteRedirect"),

editSettings = $("#" + id);

if(editSettings.length > 0 && editSettings[0].PrefixStyleSheet != 'custom-rte') {

editSettings[0]['PrefixStyleSheet'] = 'custom-rte';

editSettings[0]['StyleSheet'] = '\u002fStyle Library\u002fen-US \u002fCore Styles\u002fCustomRTStyles.css';

 RTE.Canvas.fixRegion(id, false);



// }, 2000);

}, "sp.ribbon.js");

</script> </PublishingWebControls:EditModePanel>

6. Save and publish the page layout.

7. Now create new page in SharePoint 2010 page library by using updated page layout and add “Content editor web part”. The rich text editing tool will look different. I have attached the before and after images to give you guys feelings how the end results would look like.


More Blogs

Contact us

To begin your digital transformation, get in touch.

We’re pleased to address any inquiries you might have and assist you in selecting the service that best suits your requirements.

Your benefits:
Speak To Us