2

Foll. are approaches I am aware off. Please add if there are any more, and let me know which is the best approach.

  1. Go to SharePoint designer. Take backup of existing master page. Create new master page and just before the head tag ends, and after the SharePoint:CssLink control add the following line:

    <link rel="stylesheet" type="text/css" href="/Style Library/INSERT_PATH.css" />
    
  2. Use code like following on master page after the <SharePoint:CssRegistration of the core css file:

<SharePoint:CssRegistration ID="CssRegistration1" Name="/_layouts/15/SPS.CssModule/Styles/newcssfile.css" runat="server" After="corev15.css" />

  1. Like below code:

    < asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server"> < style> /* insert css here */ < / style> < /asp:Content>

3

Your first approach is the best way to add a custom css file to a master page. Backing up master page and then creating a custom master page, adding custom CSS file to Style Library and then adding external CSS link under <head> tag. These steps are the most recommended and considered as best approach. Just make sure to add the external css link just above the content place holder named PlaceHolderAdditonalPageHead.

What @Ram has mentioned is also one of the approach but not a best practice as it has some restrictions. Adding CSS reference in Site Settings > Master Page, limits you to customize only those IDs and classes that are included on the pages by SharePoint.

  • Why above the content place holder named PlaceHolderAdditonalPageHead? Can I place it within this holder? – variable May 19 '15 at 8:58
  • Why above the content place holder named PlaceHolderAdditonalPageHead? Can I place it within this holder? – variable May 26 '15 at 9:50
3

I would recommend to use the 'Alternate CSS URL' for adding custom CSS to a SharePoint Site.

Go to Site Settings -> Master Page -> 'Alternate CSS Url'. Browse for the custom CSS file and save it. This adds the CSS to the site without any change to the master page.

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.