SharePoint 2010 - CSS references in Master Pages

Here are some of the most common ways to reference your custom CSS for SharePoint 2010. One key change over 2007 is the ability to specify After=”corev4.css” in the CssRegistration to make sure your custom CSS is referenced after the OOTB corev4.css file.

<SharePoint:CssLink runat="server" Version="4"/>
Note: Default OOTB
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>

<SharePoint:Theme runat="server"/>
Note: If a theme is enabled
Output Order:

  1. <link rel=”stylesheet” type=”text/css” href=”/_themes/[UniqueCounter#]/corev4-[u=UniqueHex#].css?ctag=[UniqueCounter#]”/>

<SharePoint:CssRegistration name=”customfolder/samplecustom.css” runat=”server”/>
Note: Alternate CSS on Server but comes before corev4.css
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/customfolder/samplecustom.css"/>
  2. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>

<SharePoint:CssRegistration name=”customfolder/samplecustom.css” After=”corev4.css” runat=”server”/>
Note: Alternate CSS on Server and comes after corev4.css.
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>
  2. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/customfolder/samplecustom.css"/>

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/samplecustom.css %>" After="corev4.css" runat="server"/>
Note: Alternate CSS In SharePoint Database for sites without publishing enabled
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>
  2. <link rel="stylesheet" type="text/css" href="/Style%20Library/emc_2010_custom.css"/>

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/samplecustom.css %>" After="corev4.css" runat="server"/>
Note: Alternate CSS In SharePoint Database for sites with publishing enabled
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>
  2. <link rel="stylesheet" type="text/css" href="/[sitename]/Style%20Library/en-US/Themable/Core%20Styles/emc_2010_custom.css"/>

<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/customfolder/samplecustom.css"/>
Note: Alternate CSS on Server by using the standard link rel. Does not need the After attribute…
Output Order:

  1. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css"/>
  2. <link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/customfolder/samplecustom.css" />

Yorum Gönder

0 Yorumlar

Ad Code

Responsive Advertisement