Where can I put my CSS, how can I link it to the main page?

I installed SharePoint 2010 on one machine in farm mode, pointing to db on another server. I would like to start site branding by doing what I initially thought was simple and simple, a link to custom CSS from the SharePoint 2010 home page.

I downloaded custom css (let it call custom.css) using the SharePoint constructor in the site resources. What syntax do I need to put in order to reference it? I tried the following:

<SharePoint:CssRegistration name="custom.css" After="corev4.css" runat="server"/> 

But the server cannot find the CSS file. I get the following error:

Unable to create cache safe URL for "1033 / styles / custom.css", file not found. Make sure the file exists in the layouts directory.

  • I suggested that I need to use SharePoint: CssRegistration - Is my assumption correct?
  • So, what exactly do I need to add to the name tag for a link to css loaded through the SharePoint constructor?
  • Am I even on the right track or will you suggest an alternative way to add this?
+5
source share
1 answer

First I would use Alternate CSS. But other options:

  • If you put the CSS file in the style library, you can do this:

    <SharePoint:CssRegistration name="<% $SPUrl:~SiteCollection/Style Library/custom.css%>" runat="server"/>

  • Put CSS on the server as 14 \ TEMPLATE \ LAYOUTS \ 1033 \ STYLES \ custom \ custom.css, and then you can do this:

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

Including a file in its own directory is considered best practice, so it does not interfere with updating files out of the box.

+8

All Articles