Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top