SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a master page and custom CSS file to brand the root site of on my SP10 server. I then applied this master page to all subsites. The style is applied properly on all sites except when I click the "All Site Content" link from one of the subsites. In this case, it still uses my master page but fails to apply the CSS.

The master page files links to the CSS with ../..Style Library/My.css (as inserted by SPD). This normally resolves properly to domain/Style Library/My.css but from the "All Site Content" (and possibly other undiscovered pages) it is trying to load domain/_subsite_/Style Library/My.css

How can I fix this?

share|improve this question
up vote 6 down vote accepted

You can try using <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/My.css %>" After="corev4.css" runat="server"/> to resolve a full path in the masterpage, though I have a funny feeling that might only work in Publishing Pages...

share|improve this answer
It works for all site templates if the css file is accessable by specified URL. – Alexander Nov 29 '11 at 20:07
But does it work in Foundation? Think that's what I should've said :P – James Love Nov 29 '11 at 20:09
The CssRegistration is a part of SharePoint Foundation 2010 Class Libraries. Thus I think it works on it :P – Alexander Nov 29 '11 at 20:22
Yeah CssReg is, but I'm on about $SPUrl, I'm sure I've seen that break in Foundation... – James Love Nov 29 '11 at 20:24
Do note, however, that the <% $SPUrl token will not resolve in SharePoint Foundation (SPF). In SPF, you will need to specify the location using a hard coded URL. Unfortunately this will be limiting if you want to use different CSS files for different languages (since you won’t have a ~language token). (Source). I like SharePoint ! – Alexander Nov 29 '11 at 20:32

I have experienced this issue a few times and I always end up doing the same thing whenever the issue occurs to me. I simply put the CSS file in the layouts folder under 14 hive.

*Program files\Common files\Microsoft Shared\Web Server Extension\14\TEMPLATE\LAYOUTS*

From here all your sites, being root or sub, can reach it.

Both <SharePoint:CssRegistration name="/_layouts/My.css" After="corec4.css" runat="server"/> and <link rel="stylesheet" href="/_layouts/My.css" /> works this way.

Style Library works too, but can be tricky. If you use Style Library to store your CSS files, try putting %20 in between Style%20Library. Like so:

<SharePoint:CssRegistration name="$SPUrl:~sitecollection/Style%20Library/My.css" After="corec4.css" runat="server"/>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.