Wednesday, October 8, 2008

Renaming SharePoint Master Page Classes

Simply said, "Just because you can, doesn't mean you should".

I have noticed that I am saying this phrase to myself more often than not with SharePoint. When it comes to SharePoint Branding you/client/developers have allot of choices to make. Its never as easy as you think.

I find myself going down the rat hole of making it overly complicated not because I don't know what I am doing, but because I know I have the power to do so.

Within SharePoint master pages you have the ability to change the default class names. For example if I wanted to change the class name within a custom master page for the quick launch
(ms-quicklaunch) to your own custom class (xyz-quicklaunch) its very easy to do in the master page. However you might be getting yourself into allot of headaches because with out really thinking about it you might have totally screwed yourself... Since you now have stripped that main class out of the page all of the default references to ms-quicklaunch will have to be added to your custom style sheet even though you might not be changing 1 single attribute for that class...

Classes that have a parent child relationship depend on some of those default classes. In the default core.css file you might have the following Example:

ms-quicklaunch .ms-navitem{
padding: 10px;
}

So in the example above this class is saying that all ms-quicklaunch classes that have ms-navitem in it will get padding of 10 pixels. if you do not reference all of those one off classes, you might find your design getting a little bit funky. This is especially true with font sizes, margins, and padding.

Therefore here is my conclusion:

If you are going to be creating a brand from scratch and removing all references to the OOTB style sheets, go ahead and rename those classes. But if you are going to keep the OOTB style sheet reference save your self the headache and keep the class names but put all of your override styles in a alternate style sheet.

No comments: