Having done branding (meaning applying custom CSS to change colors, fonts, etc.) to quite a few MOSS Site Collections, I wanted to offer a few tips and tricks to keep things clean and easy to maintain. I’ve mentioned some of these tips before, but I wanted to get them all into one post so that they could be more useful.
- Never edit default.master; take a copy and name it something logical, like myportal.master. You might need default.master again, and once you customize it, you are out of luck.
- Edit your myportal.master as you need to in SharePoint Designer. I usually limit these edits to images that I want on every site in the Site Collection and changes to Web Part Zones that should apply across the board.
- Attach a custom CSS file to your master page. I store this custom CSS in the Style Library folder and I name it the same as my master page, e.g, myportal.css. Storing it in the Style Library folder means that it will be backed up with the rest of the Site Collection. (You have set up daily backups of your Site Collection, right?!?!?)
- Definitely, definitely, definitely install the Internet Explorer Developer Toolbar. This invaluable tool does many things, but most importantly for this exercise, you can use the Find / Select Element By Click option to figure out what CSS classes you want to override.
- Only add classes and elements into the custom CSS that you are using to override the default. If you copy and paste from core.css (the default CSS file) using Designer, you will get the entire class’s definition. This will make your custom CSS much bigger than it should be and more confusing to maintain. Here’s an example…If you copy from core.css, you might have:
padding: 2px 10px 2px 5px;
If you only want to change the background color, then you should have:
since this is the only thing that you are overriding.
- Be sure that you only include each class once in your custom CSS. If classes exist more than once it will cause you problems because you will probably change the first one and then the second one will override your override!
- Try to keep the CSS classes in an order that generally goes from the top left of the page to the bottom right, just like the way you read a page. It makes finding things easier and is worth the little bit of extra effort it takes.
- Comments are good!
- Don’t forget to check in a major version of your master page and approve it, and check in your custom CSS (no need to approve here). If you don’t, you will see all of your changes, but everyone else will be asking you why you haven’t changed anything!