Hide Ribbon on SharePoint 2013 using CSS

Hi Guys,

I recently experienced the migration from SharePoint 2010 to 2013. I was earlier hiding Ribbon using the SPSecurityTrimmedControl and CSS. But in SP 2013 MS has divided whole ribbon in two section: s4-ribbonrow and suiteBar

Hiding the ribbon is as much as easier as it was in 2010 version. But here we just need to take care of above two mentioned sections. I have gone thorough some of the blogs where people are saying that we have change the html file(Seattle.html or oslo.html) and design manger will take care of creating master page for you (ref: Hide Ribbon).

But there is another traditional way of doing same, follow the given steps:

1) Open the master page file in the SharePoint designer.

2) Add the style tag to hide the ribbon for all the user:

#s4-ribbonrow, #suiteBar { display : none; }

3) Now we have to do some more changes so that at least system account can access the ribbon. Find out the <div id="s4-ribbonrow"> tag.

4) Insert the following code inside this div:

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddAndCustomizePages">

document.getElementById("s4-ribbonrow").style.display = "block";
document.getElementById("suiteBar").style.display = "block";

</SharePoint:SPSecurityTrimmedControl>

Note: Make sure before you copy and past above code. If you are getting any formatting errors after adding this code. Kindly delete all double quotes and add them again. 

5) Now save the master page and deploy or publish it to see the changes.

Happy SharePointing :)

Comments

  1. not working followed as described here, i did in SP2010 but SP2013 not working.

    ReplyDelete
  2. Hi shahzeb,

    The code mentioned in this blog will hide ribbon only for site users. System and administrators still able to see the ribbon. If you want to hide the ribbon for every single user and admin, then Please remove the code mentioned in the Step 4 of this blog.

    I wish this will solve your issue. If not, then please share some scenario with me so that I can suggest you another way to hide ribbon.

    Thanks for trying my code.

    ReplyDelete
  3. Hi Mohit,

    How can I add, step 4 code in html file of master page?

    ReplyDelete
  4. How to hide Page ribbon? i try to hide only browse and page ribbon but it's hide also Document library ribbon...plz help me

    ReplyDelete
  5. Hi Leevitha,

    If you just want to hide "Page" and "Browse" button from ribbon then you have to use following cSs:

    1) Browse link: #Ribbon.Read-title {display:none;}
    2) Page link: #Ribbon.WikiPageTab-title{display:none;}

    Hope this will help you.

    ReplyDelete
  6. Hi Pawan,

    Sorry for late reply, Yea you can add Step 4 by using few special tags. Html page has tags that start with and that show markup inside these tags and in some cases what you would find in the final corresponding master page.


    <!—MS:—>

    document.getElementById(“s4-ribbonrow”).style.display = “block”;
    document.getElementById(“suiteBar”).style.display = “block”;

    <!—MS:—>

    ReplyDelete
  7. Hi mohitvash,

    It's work with following css :

    1) browse link : UL.ms-cui-tts > LI.ms-browseTab[id='Ribbon.Read-title' {display:none!important;}

    2)Page link :UL.ms-cui-tts > LI.ms-cui-tt[id='Ribbon.WikiPageTab-title']
    { display:none!important; }

    thanks you...it's working now i was searching for the solution more than 2 days.

    But i have another probleme :
    -hiding "browse" it's work in home page and when i click on document library =>File , browse display then when i click 2 time in "File" it's not display.
    you know why?

    ReplyDelete
  8. it's working with following us for hide "Browse" on Document library : ul.ms-cui-tts > LI.ms-cui-tt[id='Ribbon.Read-title']
    { display:none!important; }

    ReplyDelete
  9. Hello

    The step 4 working, but us have to replace " cuotation because the character is wrong.

    Bye

    ReplyDelete
  10. OMG. Thank you so much!! have been going insane for a week trying to go through every css combination I could find. This finally worked to hide the user controls... You are a life saver! Have to say I am not liking sharepoint 2013 designer at all...

    ReplyDelete
  11. I don't want to hide the complete ribbon row.. I just want to hide some of the tabs in ribbon is it possible....
    Can anyone help me regarding this?

    ReplyDelete
  12. Hi Shivangi,

    Thanks for following my post. Answer to your question is yes, you can hide any control on the ribbon even tab also. You can do that either by using javascript/jQuery as well as using Css too.

    Let me know if you need more help.

    Regards
    Mohit Vashishtha
    skype: mohitvashishtha

    ReplyDelete
  13. yes, i used javascript for that nd css too it is working on all forms ( display form, edit and new form ) but i actualy also want to hide some tabs in calendar ribbon tab like calendar overlays nd etc but thr javascript or else jquery nd css is not working for hiding the tabs i don't know the reason..
    Thanks for replying..

    ReplyDelete
  14. Hi, good to know that you already using JS and CSS combination. Everything is possible using JS, hiding tab must be quite easy. It must work for calender tab too.

    I am not sure which version of SP you are working on, but I have tried to hide "Expand" Section under "Calendar" tab on SP 2013:

    document.getElementById("Ribbon.Calendar.Calendar.Expander-LargeLarge").style.display = "none";

    Have a look on result:


    My suggestion is, try to find Id of tab you want to hide and use your JS or CSS to hide and show that tab. In case you want more help let me know.

    Hope this will help you.

    ReplyDelete
  15. Thanx a lot for help..
    I am working on SP 2013 only. and i tried the same code (document.get......) by using tab id but it doesn't work for me.. can u plzz tell me whr r u placing this code for hiding i tried in calendar.aspx .. Any suggestions??

    ReplyDelete
  16. You must have to add this either on Master page or any custom JS or CSS file in your master page. Try to add there, I hope this time it will work.

    ReplyDelete
  17. Thanks for your fast reply.... I am trying it to place the code in Master page but it is not reflecting any change. Suggest me the exact position where are you putting this code in master page

    ReplyDelete
  18. Shivangi, you can place your code in the head section of the master page. I think you are missing few basic things to add before adding custom JS code. Can you just verify following things:
    1) As you have to use "$" sign in you JS code, so make sure you must be referring latest JQuery libraries in your master page.

    2) Try to check browser developer tools for any kind of error message on your page. JQuery will not work if you have any other JS related error on page.
    3) If above two points are good to go, just place an alert to check where your code is called or ingnored by master page.


    $(document).ready(function(){
    alert('Welcome to SP custom JS code');
    }

    Let me know your findings.

    ReplyDelete
  19. I tried below code on my master page ....

    $(document).ready(function(){
    alert("Welcome to SP custom JS code");
    document.getElementById("Ribbon.Calendar.Calendar.CustomViews.AddCalendar-Large").style.display = "none";
    });

    But it doesn't reflect any changes but alert is showing on the browser.

    ReplyDelete
  20. Perfect! Alert is showing that means you are on right track. I tried your code at my site. It is working fine for me. It is hiding "Calenders Overlay" button from ribbon. Can you try to add one more alert on the JS code:
    alert(document.getElementById("Ribbon.Calendar.Calendar.CustomViews.AddCalendar-Large").innerHTML);

    This should alert the inner html of the element. If It does not show any alert then try to change the id to "Ribbon.Calendar.Calendar".

    ReplyDelete
  21. Thanks a lot for trying the code..
    But its is not working for me it is just showing only alert(“Welcome to SP custom JS code”); but not showing alert(document.getElementById(“Ribbon.Calendar.Calendar.CustomViews.AddCalendar-Large”).innerHTML); I also try to change the id to “Ribbon.Calendar.Calendar" but no hope....
    Is there any other solution of my problem means as javascript is not working any other solution for hiding the tabs..

    ReplyDelete
  22. Two more ways:
    1) Using JQuery:

    $('a[id="Ribbon.Calendar.Calendar.CustomViews.AddCalendar-Large"]').hide();

    2) Using CSS:

    a[id="Ribbon.Calendar.Calendar.CustomViews.AddCalendar-Large"]
    {
    display:none;
    }

    Hope this will surly work for you :).

    ReplyDelete
  23. Thank you .. css works perfectly but thats not the complete solution as i want to hide this tabs for all users but not for admin(sp_admin) but by css it is hiding for all.. :)

    ReplyDelete
  24. Glad to know that CSS worked fine for you :).

    Hiding that for all other user except "sp_admin" can also be done. Sorry to say, but we are going out of scope to this article. I request you to drop me an email(mohitvash@gmail.com) or contact me on skype(mohitvashishtha) if you need more help.
    Thanks for using my blog. Happy Coding:)

    ReplyDelete
  25. I want to use some of the ribbon tabs display item form.. I just want to use EDIT and DELETE ITEM tabs from the ribbon .Is it possible that 2 tabs which i want to use can be on display form so that i can hide the whole ribbon.

    Thanks in advance..

    ReplyDelete
  26. Hi Anushree,

    As per my understanding Edit and Delete tabs are part of Ribbon only so there is no way to hide ribbon but show these two tabs. What you can do, in order to hide ribbon, add CSS/JS code to master page and then add content editor webpart on list display page to add some custom CSS/JS. Then inside Content Editor WP you can show ribbon and show/hide tabs as per requirement.

    Let me know if you face any issue.

    Regards
    Mohit

    ReplyDelete
  27. Reblogged this on Khotso Charles and commented:
    Awesome Post very helpful

    ReplyDelete
  28. […] Reference: https://mohitvash.wordpress.com/2013/05/07/hide-ribbon-on-sharepoint-2013-using-css/ […]

    ReplyDelete
  29. This website is completely awesome. I've search these details a
    great deal and I realised that is professional, fast to comprehend.
    I congratulate you for this article that I am going to recommend to the people friends.
    I ask you to visit the gpa-calculator.co site where each pupil or university student can find ratings grade
    point average rating. Thank you!

    ReplyDelete

Post a Comment

Popular posts from this blog

Get Comment Count in SharePoint

Configure external site as content sources in sharepoint search