Custom Styles for SharePoint 2010 Rich Html Field

October 27 2010 179 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% [?]

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

  1. Vincent says:

    Hello, I’m happy to see some great articles on your site. Septic Tank Services

  2. dexter says:

    Wow, you did such an amazing job with such a small space. It looks outstanding! garden fence repair

  3. xander says:

    Great article, Thanks for writing about that. It’s really helpful for me. Keep it up your writing. garden fence repair

  4. visit us says:

    This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information.

  5. When you need to have land excavated in Erie, PA, rely on our excavation company at. Our excavation contractors have extensive experience, which is why we are the preferred excavation company.

  6. Vince says:

    I needed to leave a little remark to help you and wish you a decent continuation. digital marketing Fort Worth, TX

  7. 重量を載せて欲しかったです。それ以外は満足しています。
    売り切れることもあるので事前にお問い合わせ下さい と書いてあったので、
    コーチ ショルダーバッグ ポピー シークイン タータン グルーヴィー 2WAY ショルダーバッグ 16048 スパンコール パテントレザー パープル系 マルチカラー 新品 ハンドバッグ 斜め掛け レザー 革 ベリーマルチカラー
    クロムハーツ 22k スーパーコピー 2ちゃんねる

  8. Welcome to Buffalo Video Pros! Meet WNY’s premier wedding videography company. If you’re looking for a high-quality video from a local Buffalo, NY videographer, you found us!

  9. Very a nice article. I really feel amazing and thank you very much for the good content.

  10. pavement says:

    Looking for a pavement service near you? You have reached the right spot! We are Commercial Paving Buffalo NY, a local company ready to provide you with the best services at the most affordable price.

  11. this is really nice to read..informative post is very good to read..thanks a lot!

  12. Francis says:

    This is a brilliant blog! I´m very happy with the comments! basement foundation repair

  13. Henry says:

    Liking this blog. THanks for posting.

    carpet cleaning Douglas

  14. James says:

    This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information.plaster walls

  15. Casual Sex in Northern Ireland is the best chat service in UK with hot ladies ready for you, check out and enjoy

  16. Nicelky dpne and written my friend!
    I started writing juset recently and realised
    lot of blogs simply rework old ideas but add very
    little off worth. It’s great to read an enlightening write-up of some real value to
    It’s going down on my list of crteria I need to replicate being a new blogger.

    Reader engagement and material value arre king.

    Some terrific suggestions; you havge definitely mqde it on my list of people to watch!

    Keep up the terrific work!

  17. belfast personals is most polular web platform for making casual sex contacts with hot girls in UK

  18. tree removal says:

    Expert tree removal, stump removal and tree trimming in St. Louis. Call Now! 314-310-7445.

  19. A great and awesome write up. An all time relevant article.

  20. Home remodeling should always be left to the pros. Let Breathe Easy Construction’s home remodeling contractors take care of you.

  21. When living in South Florida, windows become a top priority for homeowners. Without them, your house is at risk from severe weather patterns and high insurance premiums. But South Florida Windows direct, and save big time.

  22. roof repair says:

    Great effort with the work that you have put in, keep up all the great work.

  23. Tree removal says:

    Tree Trimming? No problem, We are affordable tree care company in Tuscaloosa AL.

  24. Jack Lynn says:

    Found this information really interesting. Thank you for posting it.

  25. A great and awesome write up. An all time relevant article.

  26. We spend a large amount of our time on the road, and most people have had their car break down or run out of gas once or twice. These situations can be very stressful, and trying to find a reliable local towing service that also provides emergency roadside assistance only adds to the frustration.

  27. “We paved your way to a better life through Clark County paving, paving Vancouver WA, asphalt Vancouver WA, and gravel Vancouver WA.”

  28. mshahid says:

    Wonderful article. Fascinating to read. I love to read such an excellent article. Thanks! It has made my task more and extra easy. Keep rocking. Anthony Scott Dietrich Gainesville VA

Leave a Reply