This post explains how to create a new master page with a custom stylesheet and some custom images. We do this with the following steps:

  • Install  master page picker
  • Create a new master page
  • Create a stylesheet
  • Create an images folder
  • Prepare master page
  • Edit master page
  • Deploy master page

Install master page picker
First we need a feature that is going to deploy our new master page to the sitecollections. Because the Foundation version doesn’t have a master page selector, I used this fantastic very-easy-to-install feature:

It also enables us to change the master page from within the sitecollection properties.

Create new master page
The next thing to do is to copy the existing master page.

From within Sharepoint Designer you can go to the Master Pages section and copy the v4.master in the same folder and rename it to whatever you want. I generally choose the clients name.

Tip! In the folder you also find a default.master and a minimal.master file. The default.master is the old 2007 master page. The minimal.master is a master page with only the base controls, no layout whatsoever. I always use a copy of the v4 master page and not the minimalistic one, because it’s more efficient to tweak the existing master page instead of creating a new one based on the minimal.master.

Create stylesheet
We also want to apply our own custom stylesheet to the masterpage so let’s create a stylesheet.

Go to the folder Common FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS1033STYLESThemable and create an empty mystyle.css file.

Create an images folder
Now create a new folder inside the Common FilesMicrosoft SharedWeb Server Extensions14TEMPLATEIMAGES named myimages.

Tip! We create a new folder to keep our images separated so they won´t be mixed up with the ones that come with Sharepoint. Another reason is that future editing would be easier because our images are easier to find, naturally.

Prepare master page
We are going to prepare our master page to use our custom stylesheet.

Go to Sharepoint Designer and open the edit view for the mymaster.master and click the code view. Now insert the line

<sharepoint:CSSRegistration Name="/_layouts/1033/Styles/Themable/mystyle.css" After="corev4.css" runat="server"/>

just before the </head> tag. Then save the file and accept the warning for the customized page. The After=”corev4.css” ensures that the style elements in our custom stylesheet override the default css.

Edit master page
In this example I’m going to change the color of the selected ribbon header from it’s dark grey to a solid blue color. Now browse to the sharepoint page and check the html source to find out which class is being used by the selected ribbon header. In my example the class for the header of the selected ribbon is .ms-cui-tts > .ms-cui-tt-s > .ms-cui-tt-a > .ms-cui-tt-span (do you wanna know how to find these style classes easily? Check the next tip). Now we go to our mystyle.css and create this class here and give it our blue color style.

.ms-cui-tts > .ms-cui-tt-s > .ms-cui-tt-a > .ms-cui-tt-span {
    color: #0069b0;

Save the CSS file.

Tip! I highly recommend the usage of developer tools for your browser. I always use Google Chrome with the built-in developer tools. They are very accurate and easy to use. In Chrome, rightclick the item you wish to know the style from and click Inspect element. At the right side of the window you find matched CSS Rules. You can copy a CSS rule and paste it in your mystyle.css and tweak it the way you want it.

Deploy master page
Now we wan’t to test our new master page. Before we can do that we need to select it with the master page picker we installed in the first step.

Go to your sitecollection  settings and go to the Master Page Picker which can be found under the Look and Feel category. Our new master page will be displayed in the list, select it and click ok to apply our new master page to the sitecollection.

Now go to the site and check our result. The selected ribbon header text color is now blue, thumbs up!

When you use images in your stylesheet or master page then put the image in the myimages folder and reference it with the following url


Get classnames for hover items
Tip! It may be difficult to find the hover style of some elements. In Google Chrome you can do this by rightclicking the item and leave your cursor where it is and browse the menu with up and down keys on the keyboard, then select Inspect element and press enter. At the rightside of the window you now find the classnames for the hover of the item.


Some readers ran into  an error when using their new master page. The error reads The expression prefix ‘SPUrl’ was not recognized. Please correct the prefix or register the prefix in the section of configuration. This is because SharePoint Foundation doesn’t support the SPUrl prefix out of the box.

There problem is with this line of code in the master page:
Name="<% $SPUrl:~sitecollection/_layouts/1033/Styles/Themable/mystyle.css %>"
After="corev4.css" runat="server"/>

A simple solution is to just simplify the code to this
After="corev4.css" runat="server"/>

A more time-consuming but maybe better way is this:


If you want your master page to automatically get applied with every new site you create, please read this post: