Adding CSS to custom master page

%3CLINGO-SUB%20id%3D%22lingo-sub-63909%22%20slang%3D%22en-US%22%3EAdding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63909%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20working%20on%20custom%20Master%20pages%20in%20sharepoint%202013.%20I%20am%20trying%20to%20create%20custom%20master%20page%26nbsp%3B%20in%20visual%20studio%20taking%20a%20copy%20of%20seattle.master.%20I%20have%20created%20a%20css%20file%20and%20uploaded%20the%20same%20in%20Style%20library.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20provided%20the%20link%20of%20this%20css%20file%20in%20my%20.master%20file%20in%20visual%20studio%20solution%20in%20below%20format.%3C%2FP%3E%3CP%3E%22%3CCSSREGISTRATION%20id%3D%22%26quot%3BCssRegistration1%26quot%3B%22%20name%3D%22%26quot%3B%26lt%3B%25%24SPUrl%3A~SiteCollection%2FStyle%22%20library%3D%22%22%3E%22%20After%3D%22corev15.css%22%20runat%3D%22server%22%20%2F%26gt%3B%22%26nbsp%3B%3C%2FCSSREGISTRATION%3E%3C%2FP%3E%3CP%3Esample.css%20is%20my%20css%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20add%20the%20same%20css%20file%20under%20Site%20Settings-%26gt%3BLook%20and%20Feel-%26gt%3BMaster%20Pages-%26gt%3BAlternate%20CSS%20url.%20I%20can%20see%20the%20change%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20once%20I%20deploy%20my%20solution%20in%20visual%20studio%20I%20don't%20see%20my%20changes%20reflected%20in%20my%20site.Can%20someone%20help%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63998%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63998%22%20slang%3D%22en-US%22%3EHi%2CI%20got%20the%20solution.%20When%20selecting%20the%20default%20master%20page%20under%20look%20and%20feel%2Cdefault%20master%20page%20had%20to%20changed%20under%20both%20Site%20Master%20page%20and%20System%20Master%20page%20drop-down.%20I%20had%20previously%20changed%20it%20for%20only%20Site%20Master%20Page.%20Thanks%20for%20the%20help.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63991%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63991%22%20slang%3D%22en-US%22%3E%3CP%3EYour%20CSS%20registration%20tag%20may%20contain%20errors%20-%20according%20to%20%3CA%20href%3D%22http%3A%2F%2Fyakovenkomax.com%2Fcssregistration-and-scriptlink-done-the-right-way%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20information%3C%2FA%3E%2C%20the%20reference%20to%20sitecollection%20should%20be%20lowercase.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20the%20way%20to%20include%20the%20%24SPURL%20need%20to%20be%20different.%20Please%20take%20a%20look%20at%20the%20link%20above%20and%20try%20it%20out%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EJohn%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63963%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63963%22%20slang%3D%22en-US%22%3EHi%20John%2C%20It%20is%20set%20as%20default%20master%20page.%20Under%20site%20settings-%26gt%3BLook%20and%20Feel-%26gt%3BMaster%20page-%26gt%3B%20I%20have%20selected%20my%20.master%20page%20as%20default%20from%20the%20drop%20down.%20Is%20the%20css%20registration%20that%20I%20have%20given%20is%20in%20proper%20format%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63941%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63941%22%20slang%3D%22en-US%22%3EBetter%20than%20use%20SharePoint%20Designer%2C%20use%20some%20coding%20to%20specify%20this%20master%20page%20is%20your%20default%20masterpage...bear%20in%20mind%20you%20will%20also%20have%20to%20do%20this%20in%20your%20site%20subsites%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63931%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20CSS%20to%20custom%20master%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63931%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20your%20customer%20.master%20page%20set%20as%20default%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20this%20in%20SharePoint%20Designer%3A%3C%2FP%3E%3CP%3E1.%20Mark%20your%20.master%20page%3C%2FP%3E%3CP%3E2.%20Check%20the%20toolbar%20%22Actions%22%20section%20for%20the%20%22Set%20as%20Default%22%20option.%3C%2FP%3E%3CP%3E3.%20If%20it%20is%20available%2C%20then%20your%20.master%20page%20is%20not%20the%20default%20one%20and%20you%20need%20to%20use%20the%20option.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKindly%20inform%20us%20of%20your%20result%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EJohn%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted

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

Highlighted
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
Highlighted
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?
Highlighted

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

Highlighted
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.