Register a CSS Stylesheet in your masterpage

To make use of any of the supplied CSS on my blog or elsewhere on the internet you may need to know how to add it to your site.  Often its tempting to edit the corev4.css file, but this isn’t encouraged as your changes could be overwritten by a future service pack or could be difficult to undo.  Instead here’s how to register a new CSS style sheet using SharePoint Designer 2010:

  1. If your using the default masterpage, make a copy of it and rename it (Setting the new masterpage to be the default)
  2. Upload/Create a CSS Stylesheet to a document library (e.g branding.css within a library called siteassets)
  3. Edit the new masterpage and add the following line into the PlaceHolderAdditionalPageHead section:

<SharePoint:CssRegistration name="<% $SPUrl:~site/siteassets/branding.css%>" After="corev4.css" runat="server"/>

If your using a different document library such as Style Library adjust the above line accordingly.  Once saved and checked in any styles you enter into your new style sheet can override the standard MS styles.

Incase your unsure of where to add the CssRegistration line into your masterpage here’s an example:

<SharePoint:ScriptLink language=”javascript” name=”core.js” OnDemand=”true” runat=”server”/>
<SharePoint:CustomJSUrl runat=”server”/>
<SharePoint:SoapDiscoveryLink runat=”server”/>
<asp:ContentPlaceHolder id=”PlaceHolderAdditionalPageHead” runat=”server”/>
<SharePoint:DelegateControl runat=”server” ControlId=”AdditionalPageHead” AllowMultipleControls=”true”/>
<SharePoint:CssRegistration name=”<% $SPUrl:~site/siteassets/branding.css%>” After=”corev4.css” runat=”server”/>


One thought on “Register a CSS Stylesheet in your masterpage

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s