Adding CSS to custom master page

Copper Contributor

Hi Everyone,

 

I am working on custom Master pages in sharepoint 2013. I am trying to create custom master page  in visual studio taking a copy of seattle.master. I have created a css file and uploaded the same in Style library.

 

I have provided the link of this css file in my .master file in visual studio solution in below format.

"<SharePoint:CssRegistration ID="CssRegistration1" Name="<%$SPUrl:~SiteCollection/Style Library/sample.css %>" After="corev15.css" runat="server" />" 

sample.css is my css file.

 

When I add the same css file under Site Settings->Look and Feel->Master Pages->Alternate CSS url. I can see the change .

 

But once I deploy my solution in visual studio I don't see my changes reflected in my site.Can someone help?

 

5 Replies

Is your customer .master page set as default?

 

Try this in SharePoint Designer:

1. Mark your .master page

2. Check the toolbar "Actions" section for the "Set as Default" option.

3. If it is available, then your .master page is not the default one and you need to use the option.

 

Kindly inform us of your result :)

John

Better than use SharePoint Designer, use some coding to specify this master page is your default masterpage...bear in mind you will also have to do this in your site subsites
Hi John, It is set as default master page. Under site settings->Look and Feel->Master page-> I have selected my .master page as default from the drop down. Is the css registration that I have given is in proper format?

Your CSS registration tag may contain errors - according to this information, the reference to sitecollection should be lowercase.

 

Also the way to include the $SPURL need to be different. Please take a look at the link above and try it out :)

John

Hi,I got the solution. When selecting the default master page under look and feel,default master page had to changed under both Site Master page and System Master page drop-down. I had previously changed it for only Site Master Page. Thanks for the help.