sharepoint master page css link

/ Published in: C#
Save to your folder(s)

Using the CssRegistration control is the proper way to register CSS in a SharePoint master page/layout page, but it has drawbacks. Namely, no matter what order you put them on the page the server loads them in a seemingly arbitrary order, making it difficult to ensure that your CSS is loaded in the order you want. If you want to force the order you can use the After attribute, but it will only work if you give it the full path.

Notice that corev4.css doesn’t need the full path. I believe it is using the location of corev4.css as a it’s default, so it doesn’t need the whole path.

Copy this code and paste it in your HTML
  1. <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/css_hub.css %>" After="corev4.css" runat="server"/>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.