Some of the advantages are:
- the order stylesheets are loaded (the after propertiy)
- target it for specific browsers (the ConditionalExpression property)
- avoid that the same stylesheet gets loaded multiple times
- use SPUrl in the link to the stylesheet to refer to the present site collection
Many of theese things can be done with the <link> tag as well. However you might find it easier to do it with the <SharePoint:CssRegistration...>.
To prevent a stylesheet from being loaded multiple times you must use the <SharePoint:CssRegistration...> tag.
CssRegistration vs CssLink
There is also a <SharePoint:CssRegistration...> in SharePoint for registrering stylesheet files, but when to use one or the other?- CssLink can be used only in the masterpage. It will list all css files when the page is generated.
- CssRegistration can be used in masterpages, pagelayouts or content pages. It will only tell SharePoint that this stylesheet must be included as well, but will not render it. CssLink will do the actual rendering.
See this very good article for a thorough workthrough: SharePoint CSSRegistration or Link?
See CssRegistration Class (msdn)
See CssLink Class (msdn)
No comments:
Post a Comment