Kickstart to editing styles in MOSS 2007

Before you begin:

Download and install the Internet Explorer Developer Toolbar. This is a must have tool for SharePoint Customization. The Internet Explorer Developer Toolbar (get it here FREE)

You will also need your preferred text editor, if you don’t have one, Notepad will do just fine.

Overview:

Note: I wrote this using B2TR bits so there may be moderate name changes, or menu positioning changes but nothing that should totally throw you off.

There are many ways you can add and edit CSS in MOSS 2007, the method I will discuss here is lightweight and great to get a general understanding of how style sheets work, and get aquainted with some of the class naming conventions SharePoint uses.

Set up an Alternate CSS URL:

  • Create a Publishing Site. Select Site Actions, Create Site. Then select the Publishing Tab and finally choose Publishing Site. It will take a few moments for your site to provision.
  • Open your editor of choice and create a new file and add /* Custom Styles */ to it.
  • Save it as “Custom.CSS”. If you are using notepad don’t forget to select “All Files” from the “Save as Type” drop down menu before saving, otherwise you will have a .txt extension.

Go to your website in the browser and select Site Actions, View all Site Content

  • Select the Documents Library (create one if you don’t see it). Update:  The best place to store your CSS would be the Styles Library which is already created.  I have no idea why I said to place it in the Documents Library.  You can thank Amanda for reminding me.
  • Select the Upload Drop Down, Then Upload Document. Select Browse and then browse to and select the Custom.CSS file you created to upload it.
  • Go back to the Site Actions menu, then Site Settings, Modify all Site Settings.
  • From the Look and Feel Section, Select Master Page.
  • Scroll Down to the bottom of the page until you find the “Alternate CSS URL” section. Select Specify a CSS file to be used by this publishing site and all sites that inherit from it.

22.jpg

  • Then Click Browse. Select Current Site Documents on the left and finally select your Custom.CSS file. Click Ok a couple of times to return to the site settings page.

31.jpg

  • What you just did was set up an alternate style sheet for your site. Any style you add to this style sheet will take precendence. What that means is if you know there is a certain class applied to an element in your site and you want to change it, just add the class to your Custom.CSS style sheet and it will override the previous.

Identify and Overwrite Classes:

  • Now that you are set up, you’ll need to figure out what elements of your pages you wish to change, and what classes are applied to them. That’s where the Internet Explorer Developer Toolbar comes in. If you have not downloaded and installed the IE Developer Toolbar, you’ll need to do it now.
  • Go back to the browser, and back to the default page of your website.
  • From Internet Explorer Select View, Toolbars, Developer Toolbar. This will turn the bar on. Note: If you are using IE 7 you may need to hit the ALT key to expose your file menu.

42.jpg

  • From the Developer Toolbar now exposed at the top of your screen, select View Dom. This will open a menu at the bottom of your screen.

51.jpg

  • From the bottom menu, select Find, Select Element by Click. When this is enabled, you can click any element on the page to inspect that part of the DOM (Document Object Model) and subsequently see what class is applied to what element.

6.jpg

  • As you hover over elements of your page, you will notice they highlight with a dark blue border. When you find the element you wish change highlighted, you can click it to show the information about it, such as the class which is applied to it.
  • For this example we will assume we need to change the very top horizontal bar so that is has a yellow background, rather than the default blue.
  • Hover over this element and then click it when it has a blue border. Notice that the class in the bottom tells you it’s using .ms-gloablbreadcrumb. That means that if we add that class to our Custom.CSS file, then edit it to have a yellow background, our site will update to reflect the change.

7.jpg

  • To test this, Select Site Settings, View All Site Settings. Select the Documents Library and then Check Out the Custom.CSS file so that you can edit it. You will notice your ICON change slightly once the file is checked out. When it does click it to to open it in your editor.

8.jpg

  • Add the following code to the style sheet:

.ms-globalbreadcrumb {

background-color:#FFFFB0;
}

  • Save your style sheet.
  • Back in the browser, check the style sheet back in, publish/approve it if necessary.
  • You will notice now when you refresh the page that your top bar has changed to yellow.

9.jpg
This is the basis behind overwriting the custom CSS classes in a supported, non-destructive way.

Other Important Notes:

  • These classes are originally defined in the CORE.CSS located in the 12 HIVE on the file system of the SharePoint Server.  Update:  To quickly copy/paste all properties set in the CORE.CSS file, you can “Control + Click” on any underlined class name in SharePoint Designer 2007.  Doing so will not only open the CORE.CSS file (or whatever stlye sheet your class is defined in), but also jump directly to that piece of code!
  • If there is a theme applied to the site the CORE.CSS classes are overwritten by duplicate entries in the THEME.CSS. (It’s also important to note that Themes can be somewhat confusing as when you apply your theme, the THEME.CSS (and other styles) are actually added to a file called 1011-65001.css and then applied to the site).  If you were trying to personalize a theme by connecting to the site using SharePoint Designer 2007, you need to edit the 1011-65001.css file.
  • I would consider it best practice to use the Alternatte CSS URL where possible and copy the classes “from the CORE.CSS (or theme.css)”, paste it to the CUSTOM.CSS and then modify the approrpriate properties, or add new ones.

The more comfortable you get with this the more creative you will find yours sites.

Good Luck and Happy Customizing.

You may also like...

23 Responses

  1. Steve says:

    Hi,

    I’d love to see the screenshots in your blog!

    Where are they?

    :)

    Thanks!

  2. erugalatha says:

    Hi,

    How do I get any new sites created below a site collection to inherit the stylesheet of the parent BY DEFAULT? It seems new sites created by users do not get the custom stylesheet applied – only the default gets applied.

  3. shane says:

    I usually create a folder in the Style Library for the Style Sheet and Assets/Images. That was you can reference them directly, without the need for _layouts/. Layouts should work fine as well (provided you have access to the server) of course. :)

  4. shane perran says:

    I would store your style sheets in the Style Library. (Created by default with publishing sites).

  5. Pete says:

    >erugalatha – i think you need to “publish” the css style in the Style Library ?

    My question where is the best place to store files related to this CSS style ? is it in the _Layouts

    Ta
    Pete

  6. erugalatha says:

    Hi,
    When I apply a stylesheet using this method the styles only appear for the Adminstrator … everyone else just gets the default.master page style.

    What permissions are set on my uploaded custom.css by default? Or am I missing something.

    Thanks for any help.

  7. Miller says:

    Hi Shane – Just want to thank you for a brilliant article – You have made my life so much easier today :-) … So THANKS!

  8. Bonnzo says:

    Hi,
    Great site. I am trying to customize the Logo / banner of the BlueVertical master. I use this Master only on a Team Site I am building. When I use the IE Developer Toolbar The classes .zz1_logoLinkId_1 is displayed when I click on the ‘Banner’, this does not seem to be a normal class, seem to exist only in the ether :) or embedded??? Sorry a little new to this. I can’t seem to do simple stuff like change the logo with css. Am I barking up the wrong tree here? Any help is greatly appreciated. Great Site!

    Thanks,

    BB

  9. Ridhi says:

    I m new in wss v3 , Can anybody help me how can i customize Settings.aspx and Create.aspx Pages. i want to remove or dont want to make some of menus Like materpages , sitetemplate visible .

    Whenever we Enable the tree view where this setting is stored , i hope that will be in database only .anybody have idea about table or field name.
    Please help me in finding that

    Thnaks in advance,
    Ridhi Singla

  10. Awesome “Getting Started” article Shane.
    Thanks for posting!

  11. David De Vps says:

    Hi Shane,

    Again, many, many thanks for all your efforts in explaining stylesheets for MOSS !!! I’ve been reading quite a few of your articles and all is very well explained! I’ve played with it & succeeded in my goals. However I also noticed you really need time & dedication to create some quality styles. :-)

    cheers,

    David

  12. shane says:

    I have been getting a lot of emails asking about themes in 2007. The short answer is they work pretty much the same way. They are set up on the server the same way, and you edit the styles the same way.

    In the next little while I’ll write a step by step post for creating a custom theme.

    Anna,

    When you apply a theme to a site in V3 (just like V2), the theme.css is not the file which is actually applied to the site.

    Instead your theme and the other CSS is combined forming a file called something to the effect of “ThemeName1011-65001.CSS”. This is the file you need to edit.

    Select View Source from the browser while viewing your site, you’ll notice that file is applied.

    You will find this file in the _themes folder using SharePoint Designer 2007.

    Good Luck,

    Shane

  13. anna says:

    hi, great article here.. but I am just wondering how to customize the themes. I tried to create a new custom theme and edit the theme.css. however, the theme doesn’t update accordingly. meaning the custom styles were not applied. but if I try to modify CORE.CSS, then it’s the only time i see the changes. but then again, editing the CORE.CSS is not the option im seeing, since I have to create custom themes available for different templates. if you can still post articles to customize themes other than uploading an alternative css.

    thanks! and more power!

  14. shane says:

    99% of my readers don’t use the site, they use an RSS reader. I forget sometimes people still visit the site :)

  15. shane says:

    It’s a problem with the skin – I’ve switched it to the default until I fix it. I’ll likely be moving to the SharePoint Community Kit – Blog Edition later this year when it’s released.

  16. Mike @ Macaw says:

    Shane,
    I would love to read your reaction but it seems the skin you are using doesn’t allow a reply of more than two lines in IE7

  17. shane says:

    Mike,

    To address your concern on ever having to edit the CORE.CSS style sheet. In 2007 you can inherit styles from the parent site.

    The thinking behind editing the OWS.CSS in WSS v2 was to change all sites across the farm which if you think about it will happen if all sites within a site collection inherit from the parent. You manage a single style sheet at the top level.

    Also remember, while you could specify a style sheet in SPS 2003 via the browser, you could not do it in a WSS v2 (only) scenario which you now can in WSS v3.

    As for your other concerns, it really comes down to the level of customization you need. Master Pages give you control over the layout of a page, something which wasn’t (easily) accomplished in previous versions.

    If you require basic color changes to a single site – the method in this post works great.

    If you require a globally applicable set of color changes which can be set at will, a theme works great.

    If you require a complete overhaul of your site layout, master pages work great.

    Again – it really comes down to what you need to accomplish.

    The very first step in *ANY* customization job should be to answer that exact question, “What do we need to accomplish”.

  18. Liam Cleary says:

    Hey m8,
    Great Post! Look forward to more fro you as always. :) Keep up the good work!!

    Chat Soon.

    Liam

  19. Mike @ Macaw says:

    Great post and it describes pretty much the way I also work, but what I’m wondering.. isn’t this the same as how we worked with 2003, constraining ourselves to the same design limitations we worked for over the last 3 years? Shouldn’t we start from scratch, create our own masterpages with our own classes?
    Or might it be that MOSS still isn’t as flexible as we might whish and will we be ending up changing core.css (instead of ows.css and sps.css) and some header image maintaining the structure because most clients won’t pay that amount of money needed for real customization?

  20. Bob Fox says:

    Very nice Shane. Thank you for posting this.

  21. PhilNick says:

    This is excellent, thanks.

  1. March 4, 2007

    […] MOSS Branding A couple of people recently asked me where you start if you want to teach yourself MOSS branding.    Shane Perran and Heather Solomon are my favourite branding guru’s.   These two blog entries are essential:   Shane’s starter guide:   http://www.graphicalwonder.com/?p=611   Heather’s  CSS Reference chart:   http://www.heathersolomon.com/content/sp07cssreference.htm […]

I would love to hear from you.

%d bloggers like this: