Home > Development, HTML/CSS, SharePoint > Branding SharePoint 2010 Collaboration Sites – Part 3 in a Series

Branding SharePoint 2010 Collaboration Sites – Part 3 in a Series

February 23rd, 2010 Leave a comment Go to comments

In part two, we posted about how to register our custom style sheets in a way that we could still take advantage of the new SharePoint 2010 colour switching theming engine. In this post we’ll go through how to do this without having to modify the out-of-the-box master pages or having to use custom master pages for your sites.

Delegate Controls

As I mentioned at the end of part two, the way we’re going to get our CSS added to our sites and pages is through the use of a delegate control. For those of you who aren’t familiar with delegate controls, they are essentially placeholders for you to inject your own controls via a feature. Your feature can be scoped to either Web, Site, WebApplication or Farm. I’m going to keep the explanation on delegate controls short as there’s plenty of information out there about them:

Screenshot of AdditionalPageHead delegate control in v4.master

AdditionalPageHead Delegate Control

The AdditionalPageHead Delegate

Delegate controls have a AllowMultipleControls property which when set to true, all controls keyed to that delegate are added to the page; when set to false, only the control registered with the lowest sequence value is added to the page.

All of the delegate controls in the OOTB master pages have AllowMultipleControls set to false, with the exception of one, AdditionalPageHead, which does allow multiple controls. And guess what? AdditionalPageHead is actually located in the page head, where you would normally add CSS elements! This is the perfect place for us to inject any CSS registration controls.

Putting it all together…

Let’s put together a simple solution using the Visual Studio 2010 SharePoint Tools which will:

  1. deploy our CSS file in the Themable folder in the /Layouts/1033/Styles
  2. deploy a user control into the ControlTemplates folder which uses the CSSRegistration control to register our CSS
  3. install a feature which inserts our user control onto our pages via the AdditionalPageHead delegate


Keeping it simple, all our CSS does is set the background color of the <body>. We’ll use #FFF (white) as our default background color and also decorate the rule with one of the SharePoint 2010 compile time directives to whatever we might set the “Light1” color value as through the Theme UI.

body {
background-color: #fff;

The Delegate Control

Again, nice and simple, we’re going to use the CSSRegistration control to register our branding CSS after corev4.css:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<sharepoint :CSSRegistration Name="<% $SPUrl:~sitecollection/_layouts/1033/Styles/Themable/SingChan.SP2010.Branding/branding.css %>" After="corev4.css" runat="server" />

Element Manifest

And finally we’ll define our element manifest for our delegate feature:

<?xml version="1.0" encoding="utf-8"?>
<elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <control Id="AdditionalPageHead" Sequence="80" ControlSrc="~/_ControlTemplates/SingChan.SP2010.Branding/CSSRegistrationControl.ascx" />

You’ll most likely scope your delegate feature to either Web or Site for branding purposes. I tend to scope my feature at the site collection level to achieve a consistent brand across all the webs in the site collection. If there’s a requirement to have different branding for one or two specific sites, then we can always have a second feature which deploys those overrides at a web-level scope. If you have vastly different brands across webs in your site collection, then you may want to scope only at the web level so that your brands don’t conflict or end up with any style inheritance issues.

That’s it!

If all went well, we should see the link to our style sheet emitted after the link to corev4.css!

Screen shot of HTML source of page containing a link to the branding CSS.

Our branding CSS being emitted in HTML

If all is not well, here’s the ZIP file containing the branding VS2010 solution for reference:


  1. March 22nd, 2010 at 12:23 | #1

    Hi Sing,

    How does your DelegateControl work in a case where it is deployed side-by-side with a custom MasterPage? My custom masterpage is just a slightly modified version of the starter page I downloaded from CodePlex.


  2. March 22nd, 2010 at 19:05 | #2

    Hi David,

    It should work the same, assuming the custom master page contains the AdditionalPageHead delegate control.

    If you’re using the VS2010 SharePoint 2010 tools, you can create two modules, one for your master page and one for your delegate control registration. You can then create a single feature which would include both modules if you want the delegate control to be scoped at the site collection level. If you want the delegate to be web scoped, then you can create two features instead, a site scoped feature for the master page and a web scoped feature for the delegate.

    If I’m missing something to your question, send me more details and we can figure it out!

  3. Bryan
    June 14th, 2010 at 18:46 | #3

    Hi, This was a very helpful article. I’m curious to know if this is the only way to really make a custom theme for sps 2010? I’ve tried the exporting from powerpoint and opening via SPD and manually copying additional selectors into the themed corev4xxxx.css.

  4. July 31st, 2010 at 13:09 | #4

    Is this the only method? Of course not, I’m sure there are plenty of other valid methods to creating customized branding.

    Can you explain a bit further in detail how you’re implementing your branding via SPD? Are you unghosting corev4.css at the web or site collection level?

  1. September 6th, 2011 at 01:57 | #1