Add custom.css to SharePoint 2016 masterpage
-
08-12-2020 - |
Question
anyone idea how to add custom CSS file to SharePoint 2016.
2013 way "<SharePoint:CssRegistration ID="CssRegistration2" Name="/Style Library/css/customized.css" runat="server" After="corev15.css" />"
not working.
Thanks a lot
Solution
Regardless what's the way that you are using, but the following steps should be working in SharePoint 2016
- Upload your custom CSS file to
Style Library
orSite Assets
- Go to site setting > Look and Feel > Design Manager > Publish and Apply Design > Assign Master Page based on device channel .
At Alternate CSS URL >
Specify a CSS file to be used by this site and all sites that inherit from it:
> Browse your file.Check
Reset all subsites to inherit this alternate CSS URL
if you need to apply this for all Subsite.
[Update]
After I updated your question, you were missing the format of code. so I found out you are using SharePoint:CssRegistration
, So try to use it as the following
<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/_catalogs/masterpage/css/customized.css %>" runat="server" />
Or
<SharePoint:CssRegistration ID="CssRegistration1" name="<% $SPUrl:~sitecollection/_catalogs/masterpage/css/customized.css %>" runat="server" after="SharepointCssFile" />
For more details check Starter Master Pages for SharePoint 2016