I have placed a CSS file in a directory within the 14 Hive:


I am trying to use <Sharepoint:CSSRegistration> to register it like so

<SharePoint:CssRegistration name="Family/Site.css" runat="server"/>

But it is not working for some reason. If I copy the css to the STYLES directory itself this works

<SharePoint:CssRegistration name="Site.css" runat="server"/>

What am I doing wrong?


While this is a matter of personal preference, I would suggest that instead of putting the CSS in the local file system, that you create a folder in your content database under the "/Style Library/" folder and put it there.

Some advantages of this approach:

  • Keeps your 12/14 hive cleaner which is often a forgotten area for Backup/Restore and Disaster Recovery situations
  • Keeps your CSS right within the content database that it is most likely connected to
  • If you have designers available, this also allows them to easily update the CSS without having to access the server file system
  • It also allows for versioning for the file
  • Leverages SharePoint's internal caching mechanisms

Each implementation is different but I've had the most success with this approach.


CssRegistration either takes the name of a CSS file that it assumes will be in the Styles folder or you need to provide an absolute URL to the file...Family/style.css simply won't work. It's actually Fine to deploy the file directly to the Styles folder, but if you want to isolate it I would recommend creating a folder under Layouts and placing it there. You can the reference that full URL in CssRegistration...see the reference on MSDN for details on how to dynamically reference a file under the layouts folder.


I agree with both Dave and Rob ;-) However, most of the time, I place my css files in the 14 hive so all site collections can use this centralized file. This way, I don't need to update all css files in all sitecollections. I use (like Rob said) a seperate folder like 'MyCSS', so the reference in the SharePoint:CssRegistration would be something like "_layouts/MyCSS/mystyle.css".

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.