Friday, September 3, 2010

At Last - Tame the Core CSS FIle!

Thanks to the blog of buta no le, I could solve that nasty issue of corev4.css being placed after my custom CSS file when using the SharePoint.CSSRegistration tag.

The reason I want to use that tag is that it allows the use of tokens to derive the actual site collection URL (as opposed to having to hard code the URL, and then editing the masterpage on the client site). In MOSS, SharePoint.CSSRegistration always places the core CSS file at the end of all the registered CSS files, thereby rendering useless any style overrides in your own files.

But SharePoint 2010 adds the "After" attribute to the tag. Nice! Now I can insert the following in the masterpage, and dictate my own styles over the core ones (note that the name actually needs to be enclosed in angle brackets!)

SharePoint:CSSRegistrationName="% $SPUrl:~sitecollection/style library/state.css
%" After="corev4.css" Runat="server"/>

No comments: