How do I add a css that are located in root style library in a master page?

<SharePoint:CssRegistration ID="CssRegistration1" Name="<% $SPUrl:~Site/Style Library/awesome.css%>" runat="server" After="SharepointCssFile" />

Has to work beteween site collections...

Look at @atish answer.. also see this link cssregistration


You can use ~sitecollection instead of ~Site

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

For html master page, it will be:

<!--SPM:<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/awesome.css %>" runat="server"  />-->
  • Hmm that was the first thing I tried, probably a deploy that didnt go as expected. Thnx @atish – Plexus81 Feb 12 '16 at 9:15
  • 2
    @Plexus81 I think your problem is "After="SharepointCssFile". – Christoffer Feb 12 '16 at 9:17
  • It should work. I have used it in several projects. above code I just copy/paste. Check everything properly @Plexus81 – Atish Dipongkor - MVP Feb 12 '16 at 9:19
  • 1
    @Plexus81 it could as well be a missing space and the end of .css "~Site/Style Library/awesome.css%>" But Atish answer about changing from site to sitecollection is the correct way to have it working for root sites as well as "Sub" site collections. – Christoffer Feb 12 '16 at 9:24
  • 2
    @Plexus81 Of course you can, but should it not refer to a actual .CSS file? :) sharepoint.stackexchange.com/questions/74508/… – Christoffer Feb 12 '16 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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