Last modified at 3/14/2014 3:10 PM by Koen Zomers

‚ÄčIt is possible to add custom styles to the ribbon in SharePoint 2013 (and SharePoint 2010 in that matter, the procedures are the same). This allows content editors to choose from your specific predefined styles easily to format their text.


From the developer standpoint this is also interesting as the eventual HTML will be assigned the class name you assign to your custom style. This can then ideally be used in combination with JavaScript/jQuery to transition it to something fancy like a jQuery Syntax Highlighter.


Now how do we accomplish this adding our own styles to the Styles section in the ribbon? In this guidance I'll show you how to do it through SharePoint Designer. If you want to roll this out over multiple environments, i.e. in a development, test, acceptance, production (DTAP) street, it would be wise to add the CSS to a solution package and deploy it through a feature.

  1. Open SharePoint Designer and connect to the sitecollection where you wish to add the custom style

  2. After connecting to your sitecollection with SharePoint designer, in the left navigation section click on All Files and after that click on Style Library on the right.


  3. Right click somewhere in the white area on the right, click on New and then on CSS.


  4. Give the CSS file any filename you would like, I named mine ZomersWikiStyles.css

  5. Right click on the CSS file you have just added and click Open to open the file in edit mode.


  6. Now add a style section in this CSS file for each style you wish to add to the ribbon. There are two sections in the styles section in the ribbon you can add your custom style to: Page Elements and Text Styles.
    Depending on which of the two (Page Elements or Text Styles) you wish to add your custom style to, you use the following syntax for the class name you specify in your CSS file:

    • For a style in the Page Elements section, use the format:<yourowndefinedname>
      Note that instead of using span, you can also use H1, H2, H3, H4 which will then be wrapped around the text to which this Page Element style is being added

    • For a style in the Text Styles section, use the format: .ms-rteEStyle-<yourowndefinedname>

    Within your class definition, add the following line which should be there for either of the two types of styles:

    -ms-name:"The name visual in the ribbon for your style";

  7. SharePoint-Ribbon-AddStyle-SharePointDesignerRibbonStyle.png
    For the rest its up to you what you wish to add to the class to form your style. See two sample implementations below which cause the two extra styles to be added to the ribbon as shown abov.

  8. There's one more step to this. That is adding a reference to this new stylesheet to either your masterpage if you wish it to be available on all pages which use your masterpage or to a specific pagelayout if you only want it to be available in pages that use that specific page layout. In this sample I will add the style to a pagelayout.

    In SharePoint Designer, in the Navigation section, click on Page Layouts.

  9. Right click on any pagelayout you wish to edit, in this example I have made a custom pagelayout named ZomersWiki.aspx to which I am going to add the style. In the popup menu, click on Edit File in Advanced Mode


  10. In your pagelayout, within the asp:Content section with the ContentPlaceHolderId named PlaceHolderAdditionalPageHead, add the reference to your style sheet:

    <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/ZomersWikiStyles.css %>" runat="server"/>


  11. Save your files. Don't forget to check them in and publish them as a major version in case you have versionining enabled on your style library which it is by default so your changes will be available to all users. Close SharePoint Designer and head back to SharePoint. Any page based on the above pagelayout will now have the styles you defined added to the ribbon.