Thursday, September 16, 2010

Hide First Tab in SharePoint 2010 Navigation

I created a blog post on this for SharePoint 2007 HERE: But SharePoint 2010 is a bit more complex. Since it uses UL’s and Li’s for it’s navigation it is a bit harder to hide just one element.

image

You will notice that the Home tab actually is the first node and then has a child UL which represents the rest of the navigation Items. So the approach is to hide the first <li> <a> (display: none) and then simply just use (display:block ) to show the hidden <ul> <li> <a> tags.

Here is the CSS you could use to hide just the first node (home) tab in a SharePoint 2010 application:

.s4-tn li.static > a{
display: none !important;
}
.s4-tn li.static > ul a{
display: block !important;
}

image

Enjoy!

7 comments:

Taylor Pilewski said...

I'm having a hard time determining what code to replace in the css file.

Could you be more specific about what to replace?

Or do you mean that I should just add that code from your post to the css file all together?

Just looking for more specific direction.

Thanks! :)

Anders Sylvest said...

Hey Taylor.

Yes, you should just add the code to your CSS file. The rules will override the rules in SharePoints default stylesheet. :-)

Anders

c_marius said...

Hi, SharePoint controls used for menus, navigation bars, etc. have parameters that control the Sitemap and navigation controls, including level to show, 1st element!
Have you considered that already?

Abhishek Agrawal said...

That is what I was looking for,Thanks a lot for posting this.Its saved lots of time and frustation.

Matthias said...

Hi! That's great! But I also need to choose 3 other top-navigation links to show them on a different place. How can I select them?!

تهاني said...

Thanks a million

agitprop said...

@c_marius

SP2010 uses the Sharepoint:ASPNet navigation control, which doesn't have all the properties you've mentioned. There are blog posts out there that show how to emulate SP2007 behavior by using legacy controls.