Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

1) In My custom master page I have registered my CSS as follows,

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

Now I have my folder mycssfolder, with me. Where should I place it? I placed in the root directory under my port 2222.

2) In my CSS I have a reference to an Image that reside in mycssfolder, now is my reference correct? Where should I place this folder? [Actual folder mycssfolder/images/mainBG.jpg]

background:url(../images/mainBG.jpg)

3) Now finally If I am deciding to place my Entire folder mycssfolder in a document library called 'css'. Then how should I change these entries?

Thanks.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

1) You can place your styles sheets in the Style Library. With SharePoint Designer way to get there is to navigate to "All Files -> Style Library". There you can create your mycssfolder to keep your custom CSS's separate. You can also navigate to Style Library using a browser from Site Actions, or directly with URL http://YOURURL/_catalogs/masterpage/Forms/AllItems.aspx.

Then in your master page you would reference to the CSS like /Style Library/mycssfolder/css/mycss.css.

2) That reference looks correct. In my example you should place it in /Style Library/mycssfolder/images/mainBG.jpg

Difference with this and having files under _layouts is that Slide Library is normal SharePoint list, so it will have versioning, permissions, etc. _layouts is probably slightly quicker to work with as you can use any editor you wish and saving modifications to a server hard drive is quicker than saving a file with SPD to SharePoint database.

Then again, you need to separately have backups of the stuff you put in _layouts, where as if the files would be in Style Library, they would be backed the same time you back up SharePoint database or farm.

So both have pros and cons.

share|improve this answer
    
As I understand the Styles Library locates in the RootWeb of a site collection, in theory the user can have access to the subweb and don't have rights to the root web. How this issue can be resolved? –  Alexander Jan 31 '12 at 7:07
    
Such scenario is possible. You need to grant read permission to all users into the Style Library list. Also these style libraries are site collection specific, so you need to consider caferully which option to choose if you have multiple site collections. –  Jussi Palo Jan 31 '12 at 7:15
1  
There is also stackexchange question from related about where to place css files - sharepoint.stackexchange.com/questions/2219/… –  Kai Jan 31 '12 at 7:27
    
Thanks a lot jussi for your detailed help, and currently what I did was I created a document library called mycssfolder and put all other folders and files inside that. This is working, correct, whether any draw back for this method? anyways +1 –  Jithu Jan 31 '12 at 7:39

If your css folder structure is like following:

MyCssFolder\MyCssFile.css
MyCssFolder\images\image1.jpg
MyCssFolder\images\image2.jpg

You can reference image in your MyCssFile.css like this:

background:url(images/image1.jpg)

This is the best becuase you can move your MyCssFolder any where and you don't need to change the path of image in css because it is relative to that css file.

share|improve this answer

There is a STYLES folder in Layouts folder. You can place CSS there. Then you can use name="/_Layouts/STYLES/mycssfolder/css/mycss.css". But it is not a rule. You can place your css in any place under Layouts folder.

share|improve this answer
    
Thanks a lot Alex. –  Jithu Jan 31 '12 at 7:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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