Custom Styles for SharePoint 2010 Rich Html Field

October 27 2010 229 comments

A typical requirement from a client is to be able to incorporate their own custom styles for the Rich Html Field. Allowing their public relations department to apply nice text formating for paragraphs with some Comic Sans Hotness might not be the best practice in here, so let’s be careful out there. The best scenario is only to allow custom formatting for headings, paragraphs and maybe a few different table styles but let’s go!

First, open up the page layout containing the HTML editor and add PrefixStyleSheet property for the RichHtmlField:


Now, the default value for the property is ms-rte. We are going to redefine this to my-rte. Do not use any uppercase characters in the property value as apparently those wont work. Deploy the page and open it in edit mode to see the desired effect. The styles collections are now empty in the Ribbon.

We now have to define our own styles prefixed with the string my-rte. I’d suggest that you put these style declarations in a separate stylesheet to avoid javascript errors caused by complicated and hard-to-parse stylesheets. Let’s name our new stylesheet rte.css and add a few declarations there.

The Markup Collection

Let’s say I want to have an option to add a level 1 heading or an H1 tag for the given page via the Markup Styles dropdown list:

Step 1 – introduce the tag:
  -ms-name:"my level 1 heading";

Step 2 – add the styles to the tag:

    font-size: 150%;

Save the rte.css and make a reference for it in your master page, page layout or even use an alernative css. If you want your clients to be able to edit the styles themself, you could upload the rte.css in the Style Library and reference it there.

I have saved the file directly in the 14-hive /_layouts/my/ -folder and use a quick reference in the master page:


Deploy and reload the page, fire up the edit mode and navigate to the ribbon where you can see your new style in action.

Your first custom style

Adding new elements is easy once you get to know the logic. Here’s an example of a parapgraph with nice rounded corners and superb font on modern browsers (note that I have combined the introduction and style values in one declaration):
    -ms-name:"My CSS Rounded Paragraph";
    background: #808;
    color: #fff;
    border: 3px solid #f0f;
    text-transform: uppercase;
    text-align: center;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    box-shadow: 0 0 20px #000;
    -moz-box-shadow: 0 0 20px #000;  
    -webkit-box-shadow: 0 0 20px #000;
    padding: 10px;
    font: bold 2em Comic Sans MS;

Even Grammatical Errors Wont Silence the Comic of Sans

The Styles Collection

The Styles collection can be populated with the same way by changing the Element-suffix into Style ie.:

  -ms-name:"I am pink";
  color: #f0f;

This (P)arapgraph is Pink

Other Items

I’d suggest that you check out the default HTML editor styles in /Style Library/en-us/Themable/Core Styles/htmleditorstyles for quick reference how to style the other elements, including table styles on the Ribbon.

Popularity: 14% [?]

229 comments to “Custom Styles for SharePoint 2010 Rich Html Field”

  1. Thanks! It has made my task more and extra easy. Keep rocking.

  2. Naja says:

    Wow perfect music . I love this!concrete contractors Seattle Wa

  3. You share it great, thanks for the post.I must say that I am impressed with the site.

  4. Excellent work for creating this kind of content. Thanks for sharing

  5. trans toulon says:

    trans toulon is great for your own sexy chat contacts with hot girls in France

  6. This is a great blog!

  7. The post is very informative keep posting.

  8. Carl says:

    thanks for this usefull article, waiting for this article like this again.roofing contractor niskayuna ny

  9. At Best Boat Detail Vancouver we provide specialty cut and wax services to leave your boat looking as clean and shiny as possible. The correct procedure involved in boat waxing involves the use of specialized boat waxing equipment in conjunction with heavy-duty marine waxing agents.

  10. Nate says:

    I liked your post and I hope you will have many entries or more. concrete foundation san antonio tx

  11. None says:

    Great site with an awesome post. Thanks for sharing.bathroom remodel kansas city

  12. Carla says:

    Pretty! This is really a wonderful post. Thanks for providing this details.personal trainers in boston

  13. Classificadosx é um serviço de ligação para trabalhadores do sexo adultos. Este site destina-se a servir de meio de comunicação entre si e as prostitutas da sua área. Pense nisso como o Uber para as suas necessidades sexuais.

  14. Viptransex says:

    Viptransex Besonders gut gefüllte Profile mit einem oder mehreren Fotos sind hier im Handumdrehen erfolgreich. Die Seite wird auch von Experten als eine der zuverlässigsten Casual Dating Seiten in Deutschland angesehen. Mit einem kostenlosen Konto und der Möglichkeit, Standardnachrichten zu versenden, können Sie interessierten Nutzern sofort Ihr Interesse bekunden.

  15. Sexadvertenties heeft een matching systeem dat je BBW dating avontuur makkelijker maakt. U kunt de profielen van uw matches bekijken en zien of er iemand bij is waarin u geïnteresseerd bent. Matching-algoritmes sturen matches op basis van je interesses, voorkeuren en locatie.

  16. Ladyxena says:

    Ladyxena est l’une des applications de chat vidéo gratuites les plus populaires, qui vous met en relation avec différentes personnes dans le monde entier. On pourrait croire qu’il s’agit d’un site de chat de plus, mais la particularité qui le rend unique est la confidentialité que le site maintient pour ses utilisateurs, bien qu’il s’agisse d’un site gratuit.

  17. This is really a wonderful post. Great idea!

  18. Dental Boise says:

    Toothaches can sometimes drive us to sleepless nights or even loss of appetite. Most people don’t realize that a simple toothache can have the potential to increase the risk of a permanent and serious problem when left untreated. If this case happens to you or any dental problem you’re facing, the only person that can help you is your dentist.

  19. Whether your fractured tooth is caused by injuries or general wear and tear as people age, a visit to your dentist is advised. If you experienced any of these signs and factors, you can visit the nearest dental clinic in your area.

  20. Theo says:

    You have a nice information. Thanks!
    business coaching services arkansas

  21. Kris says:

    Thank you for this Great and informative site! boston iron works

  22. Mavy says:

    So many great and useful tips here. Thanks for sharing! Residential Window Washing

  23. For lonley guys to find casual chat contacts Shemale Marseille

  24. Find fine hot ladies ready for casual contacts in France Montpellier Sexe

  25. Hey man, about fine ladies in EU you must check Onlinesex in Freiburg

  26. If you have some extratime find fine Italian ladies at Annunci Trans Firenze

  27. Italian ladies waiting for casual contacts with you Shemale Palermo

Leave a Reply