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

I'm using a custom Masterpage which references a custom CSS File in the header like so:

<Sharepoint:CssRegistration Name="CUSTOM/Custom.css" runat="server"/>

My custom CSS file is simply a copy of the corev4.css with some minor tweaks. However, when debugging my site I noticed that it is inheriting styles from both the corev4.css and my new Custom.css file.

I'd like to only reference my Custom.css file, leaving the corev4.css out of the picture. Is this possible to drop the corev4.css reference on my custom Masterpage?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I would advise against this...I would also advise against having an exact copy of the coreV4.css file.

Having both these files is going to beef up the load times and increase the needless amount of code the browsers need to go through.

Change your CSS registration to the following line. I also always add it after the CoreV4.css not that it makes a difference if you have the "After"

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

In your custom.css file i would only add styles which you want to change, this will automatically override and take precedence over the coreV4.css. My "Custom.css" always starts pretty much blank aside from a few default styles I always use.

share|improve this answer
    
The "After" actually ended up being the key here, as some of my styles in Custom.css were still being overridden by the corev4. Thanks –  Lando Feb 20 '13 at 20:56

To do this properly, leave corev4.css alone and define your own custom CSS file that includes only the CSS classes that you want to override. CSS loads in order so as long as your custom CSS is loaded after corev4, your styles will be applied. Since your new file includes only the CSS classes that were modified, it will also be much easier to manage than if it included everything.

Another reason to do it this way is that Corev4.css is a system file and as such is subject to update in a SharePoint Service Pack or Cumulative Update. If you are using your own copy of the file, then you will not get the update leading to a user interface that could vary from flaky to unusable, depending on the nature of the fix.

share|improve this answer
    
Beat me to it Dave! –  Stephen Feb 20 '13 at 17:46

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.