14.5 Themes 411
Chapter 14
You can also reference your custom style sheet from your master page by
using the SharePoint
CssRegistration control. In a master page, Share-
Point calls core.css using the SharePoint
CssLink control. Any references to
custom style sheets should appear after this tag. Using the
CssRegistration
control has its drawbacks, namely the fact that the control does not actually
guarantee the order in which the specified style sheet is loaded. This is not
really a problem if your custom style sheet references styles that do not exist
in core.css, but if you are using your custom style sheet to override the styles
in core.css, you should look to using another method such as setting the
alternate CSS URL property. Alternatively, you can use a standard ASP.NET
link control to reference your custom style sheet directly from your master
page. If you place the
link control after the SharePoint CssLink control,
your custom styles will be loaded after core.css. Figure 14.28 shows the
HTML for referencing a custom style sheet using both the
CssRegistra-
tion
control and the ASP.NET link control. The drawback of using the
link control method relative to the alternate CSS URL method is that the
style sheet only affects pages that inherit the master page containing the refer-
ence. As we mentioned earlier in the chapter, the majority of the pages in
the _layouts directory are controlled by the application.master, which means
that the application.master would have to include the
link control.
Microsoft does not support the modification of system pages such as applica-
tion.master. From a best practice standpoint, you should try to perform as
much customization as possible through the use of custom style sheets and
then leverage the alternate CSS URL setting to achieving a consistent look
and feel with respect to style settings throughout your site collection.
It is important to note that, as with master page settings, new sites do
not inherit the alternate CSS URL setting from the parent. As with master
pages there are several techniques to choose from should you want newly cre-
ated sites to reference a specific alternate CSS file upon site creation. These
techniques are discussed in Chapter 15, Site Definitions nad Templates and
Chapter 16, Features.
14.5 Themes
Designing a Web page so that it is both visually appealing and effective is of
paramount importance to the ultimate success of the site. Not all Web sites
are created by professional Web designers who know all of the intricacies and
Figure 14.28
SharePoint:
CssRegistration and
ASP link tags.
Get Microsoft SharePoint 2007 Technologies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.