3

How to put a reference for a CSS in aspx page layout in SharePoint 2016

 <SharePoint:CssRegistration name="&#60;% $SPUrl:~sitecollection/Style Library/Test/Custom.css %&#62;" 
runat="server" after="corev15.css"/>

or

 <link rel="stylesheet" 
 href="/_layouts/1033/styles/HtmlEditorCustomStyles.css" type="text/css"
    media="all" />

which is the correct way of doing it ?

3

Its primarily opinion based answer.

But if you want to add in aspx page then I would definitely go with

<link rel="stylesheet" href="/_layouts/1033/styles/HtmlEditorCustomStyles.css" type="text/css" media="all" />

But if you want add in MasterPage then you must go with

<SharePoint:CssRegistration name="&#60;% $SPUrl:~sitecollection/Style Library/Test/Custom.css %&#62;" 
runat="server" after="corev15.css"/>

Also if you need to add for particular site then here is the best approach for you.

| improve this answer | |
4

The better way of loading CSS in SharePoint world is always using CssRegistration tags. You can always specify the order of script load, conditional script load, also when using same master page at root level and multiple sub-site level, it provides you ease of creating URL.

See this link for more.

| improve this answer | |

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.