You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Make custom CSS files themable in SharePoint
3
-
ms.date: 05/20/2020
3
+
description: Learn how to add comment-style markup to a CSS file so that it can be used in the SharePoint theming engine.
4
+
ms.date: 06/21/2021
4
5
ms.prod: sharepoint
5
6
ms.assetid: b8c82c77-c836-47f9-a11e-6c9c656d436b
6
7
localization_priority: Priority
7
8
---
8
-
9
-
10
9
# Make custom CSS files themable in SharePoint
11
10
12
11
Learn how to add comment-style markup to a CSS file so that it can be used in the SharePoint theming engine.
13
12
14
13
## Introduction to annotations
15
-
<aname="Intro"> </a>
16
14
17
15
Annotations are special comment-style markup that tell the SharePoint theming engine how to theme properties in a CSS file. When a theme is applied to a site, the theming engine replaces the CSS property values with the appropriate theme values. In SharePoint, you can use annotations to change the color, font, or background image. You can also recolor an image. If you are using custom CSS files, you must add these annotations to the CSS files if you want to use them with the SharePoint theming engine. If you apply a theme to a site that uses custom CSS files, and you haven't added annotations, the CSS properties remain unchanged. This can result in a site that has a mismatched design.
18
-
19
-
20
-
16
+
21
17
This article describes the available annotations and how to register CSS files.
22
-
23
-
24
-
18
+
25
19
For more information about custom themes, see [How to: Deploy a custom theme in SharePoint](how-to-deploy-a-custom-theme-in-sharepoint.md) and [How to: Create a master page preview file in SharePoint](how-to-create-a-master-page-preview-file-in-sharepoint.md).
26
-
27
-
28
-
29
20
30
21
## Add annotations to custom CSS files
31
-
<aname="annotations"> </a>
32
22
33
23
Annotations tell the SharePoint theming engine how to theme properties in a CSS file. This section describes the available annotations and how they can be used.
34
-
35
-
36
-
37
24
38
25
### ReplaceColor annotation
39
-
<aname="replaceColor"> </a>
40
26
41
27
The **ReplaceColor** annotation replaces the color value with the specified theme color. It can be used with CSS properties that define a color value, such as **color**, **background-color**, **border**, and so on.
42
-
43
-
44
-
45
-
The following shows the format for the **ReplaceColor** annotation.
46
-
47
-
48
-
49
28
29
+
The following shows the format for the **ReplaceColor** annotation.
Replace _ColorSlot_ with the annotation name of the color slot to use. To see a list of available color slots, see the [Color slot mapping](color-palettes-and-fonts-in-sharepoint.md#colorSlots) section in [Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md).
59
-
60
-
61
-
35
+
Replace `ColorSlot` with the annotation name of the color slot to use. To see a list of available color slots, see the [Color slot mapping](color-palettes-and-fonts-in-sharepoint.md#colorSlots) section in [Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md).
36
+
62
37
Use the optional **themeShade** parameter if you want to darken the theme color. Replace _ShadeValue_ with a numeric value from 0.0 (no change) to 1.0 (darkest).
63
-
64
-
65
-
38
+
66
39
Use the optional **themeTint** parameter if you want to lighten the theme color. Replace _TintValue_ with a numeric value from 0.0 (no change) to 1.0 (lightest).
67
-
68
-
69
-
40
+
70
41
Use the optional **opacity** parameter if you want to specify the opacity of the theme color. Replace _OpacityValue_ with a numeric value that specifies the opacity setting. The opacity setting ranges from 0.0 (fully transparent) to 1.0 (fully opaque).
71
-
72
-
73
-
42
+
74
43
The following shows examples of the **ReplaceColor** annotation being used in a CSS file.
The **ReplaceFont** annotation adds the specified theme font to the list of available fonts. It can be used with the **font** and **font-family** CSS properties.
93
-
94
-
95
-
96
-
The following shows the format for the **ReplaceFont** annotation.
97
-
98
-
99
-
100
-
101
-
102
52
103
-
```
53
+
The following shows the format for the **ReplaceFont** annotation.
104
54
55
+
```css
105
56
/* [ReplaceFont(themeFont:"FontSlot")] */
106
57
```
107
58
108
59
Replace _FontSlot_ with the name of the font slot to use. To see a list of available font slots, see the [Font slots](color-palettes-and-fonts-in-sharepoint.md#fontSlot) section in [Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md).
109
-
110
-
111
-
60
+
112
61
The following shows an example of the **ReplaceFont** annotation. In this example, if the **body** font slot is defined as Courier in the theme, Courier will be added as the first item in the list of available fonts in the **Choose the Look** wizard.
The **ReplaceBGImage** annotation replaces the background image in the CSS file with the theme background image. It can be used with the **background** and **background-image** CSS properties.
125
-
126
-
127
-
128
-
The following shows the format for the **ReplaceBGImage** annotation. The **ReplaceBGImage** annotation can also be used with the **AlphaImageLoader** filter to support earlier versions of Internet Explorer.
129
-
130
-
131
-
132
-
133
68
69
+
The following shows the format for the **ReplaceBGImage** annotation. The **ReplaceBGImage** annotation can also be used with the **AlphaImageLoader** filter to support earlier versions of Internet Explorer.
134
70
135
-
```
71
+
```css
136
72
/* [ReplaceBGImage] */
137
73
```
138
74
139
-
140
75
### RecolorImage annotation
141
-
<aname="replaceBGimage"> </a>
142
76
143
77
The **RecolorImage** annotation recolors the image specified.
144
-
145
-
146
-
147
-
The following describes the format of the **RecolorImage** annotation.
148
-
149
-
150
-
151
-
152
78
79
+
The following describes the format of the **RecolorImage** annotation.
Replace _ColorSlot_ with the annotation name of the color slot. To see a list of available color slots, see the [Color slot mapping](color-palettes-and-fonts-in-sharepoint.md#colorSlots) section in [Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md).
160
-
161
-
162
-
86
+
163
87
Use the optional **method** parameter if you want to specify the recoloring method.
164
-
165
-
166
-
88
+
167
89
Use the optional **includeRectangle** parameter if you want to recolor only a specific region of an image. Replace _x-Setting_, _y-Setting_, _RegionWidth_, and _RegionHeight_ with the x-coordinate, y-coordinate, width, and height of the region that you want to recolor.
168
-
169
-
170
-
90
+
171
91
The following shows examples of the **RecolorImage** annotation being used in a CSS file.
## Upload the CSS file to the Themable folder in the Style library
184
-
<aname="uploadCSS"> </a>
185
97
186
98
Place the custom CSS files in the Themable folder in the Style library (not the Themable folder in the Master Page Gallery). Only CSS files that are stored in the Themable folder in the Style library are recognized by the theming engine. The Themable folder is created automatically for publishing sites. Otherwise, you can create the Themable folder in the correct ___location (http:// _SiteCollectionName_/Style Library/ _language_/Themable/).
187
-
99
+
188
100
> [!NOTE]
189
-
> The name of the _language_ folder must be in the 4-digit format _ll-cc_ to identify the language and culture, respectively. For example, en-us or ar-sa. For more information, see [Language identifiers and OptionState Id values in Office 2013](https://technet.microsoft.com/library/cc179219.aspx).
190
-
191
-
192
-
101
+
> The name of the _language_ folder must be in the 4-digit format _ll-cc_ to identify the language and culture, respectively. For example, en-us or ar-sa. For more information, see [Language identifiers and OptionState Id values in Office 2013](https://technet.microsoft.com/library/cc179219.aspx).
193
102
194
103
CSS files must be checked in and published. If CSS files are changed, you must reapply the theme for the changes to be recognized.
195
-
196
-
197
-
198
104
199
105
## Register the CSS file
200
-
<aname="registerCSS"> </a>
201
106
202
107
You must register the CSS file with a master page before the CSS file can be used by the theming engine. This directs the master page to the CSS file when you apply a theme to a site. To register a CSS file, you add a **<SharePoint:CssRegistration>** element to the **<head>** element of the master page. The following shows the format of the **<SharePoint:CssRegistration>** element.
Replace _CSSFileLocation_ with the ___location of the CSS file.
213
-
214
-
215
-
216
-
The following is an example of an **<SharePoint:CssRegistration>** element.
217
-
218
-
219
-
220
-
113
+
Replace _CSSFileLocation_ with the ___location of the CSS file.
221
114
115
+
The following is an example of an **<SharePoint:CssRegistration>** element.
222
116
223
117
```HTML
224
118
<head>
@@ -229,34 +123,13 @@ The following is an example of an **<SharePoint:CssRegistration>** element.
229
123
230
124
> [!NOTE]
231
125
> The **%$SPUrl** token cannot be used on SharePoint Foundation 2013. You must use a URL to specify the ___location of the CSS file.
232
-
233
-
234
-
235
-
236
126
237
127
## See also
238
-
<aname="addresources"> </a>
239
-
240
-
241
-
-[Themes overview for SharePoint](themes-overview-for-sharepoint.md)
242
-
243
-
244
-
-[How to: Deploy a custom theme in SharePoint](how-to-deploy-a-custom-theme-in-sharepoint.md)
245
-
246
-
247
-
-[Upgrade custom themes and CSS to SharePoint](upgrade-custom-themes-and-css-to-sharepoint.md)
248
-
249
-
250
-
-[How to: Create a master page preview file in SharePoint](how-to-create-a-master-page-preview-file-in-sharepoint.md)
251
-
252
-
253
-
-[Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md)
254
-
255
-
256
-
-[SharePoint Team Blog: Show off your style with SharePoint theming](https://www.microsoft.com/en-us/microsoft-365/blog/2012/10/29/show-off-your-style-with-sharepoint-theming/)
257
-
258
-
259
-
-[SharePoint Design Manager branding and design capabilities](sharepoint-design-manager-branding-and-design-capabilities.md)
260
-
261
-
262
128
129
+
-[Themes overview for SharePoint](themes-overview-for-sharepoint.md)
130
+
-[How to: Deploy a custom theme in SharePoint](how-to-deploy-a-custom-theme-in-sharepoint.md)
131
+
-[Upgrade custom themes and CSS to SharePoint](upgrade-custom-themes-and-css-to-sharepoint.md)
132
+
-[How to: Create a master page preview file in SharePoint](how-to-create-a-master-page-preview-file-in-sharepoint.md)
133
+
-[Color palettes and fonts in SharePoint](color-palettes-and-fonts-in-sharepoint.md)
134
+
-[SharePoint Team Blog: Show off your style with SharePoint theming](https://www.microsoft.com/microsoft-365/blog/2012/10/29/show-off-your-style-with-sharepoint-theming/)
135
+
-[SharePoint Design Manager branding and design capabilities](sharepoint-design-manager-branding-and-design-capabilities.md)
0 commit comments