How do I convert my web parts into tabs?

Here is a neat trick that can make your team pages a lot more efficient. Using jQuery and jQuery UI’s tabs feature, we can automatically “tabify” all web parts contained within a web part zone.


  1. This solution has been tested to work for SharePoint 2013 and SharePoint within Office 365 only.
  2. All web parts that you want to “tabify” should be placed within the same web part zone on your page.



    1. Create a new .txt. file with the following code in it.  Upload the file somewhere on your website.  For the sake of this example, I placed the file on my site’s /siteassets/ folder.  Therefore, the URL will be /samples/siteassets/tabify.txt/
      <script type="text/javascript" src=""></script>
      <script type="text/javascript" src=""></script>
      <link rel="stylesheet" type="text/css" type="text/javascript" href="" >
      <script type="text/javascript">
      var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value ? document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value == "1" : false;
      var wikiInEditMode = document.forms[MSOWebPartPageFormName]._wikiPageMode ? document.forms[MSOWebPartPageFormName]._wikiPageMode.value == "Edit" : false;
      function tabify() {
         if (!inDesignMode && !wikiInEditMode) {
                  var tabifyMeDiv = $(this);
                  var theZone =    tabifyMeDiv.closest(".ms-webpart-zone").length > 0 ?
                              tabifyMeDiv.closest(".ms-webpart-zone") :
                  var WebPartDivIDs = [];   
                  var tabsWebPartIDSuffix = tabifyMeDiv.closest(".ms-webpartzone-cell").attr('id').replace('MSOZoneCell_WebPart','');   //This will return something like WPQ2
                  //Put the Web Part Title for all the Web Parts you wish to exclude from being tabbed into the array below.
                  //These web parts will be moved above or below the tabs area (depending on the existance of the data-location attribute of your .tabifyMe div)
                  //The excluded web parts will display in the same order specified in the array below
                  var excludedWebParts = [];
                  if($.trim(tabifyMeDiv.text()) != "") {
                     excludedWebParts = tabifyMeDiv.text().trim().split(",");
                     //Finds webparts whose titles match the comma-separated list of titles inside the .tabifyMe div and pushes thir IDs to the array excludedWebParts
                     for (i = 0; i < excludedWebParts.length; i++) {
                        excludedWebParts[i] = theZone.find('.ms-webpart-titleText span').filter(function() {   
      return $(this).text() === excludedWebParts[i].trim() || $(this).text().indexOf('tabify.txt') > -1;
                  // A true value indicates the tabs will be placed ABOVE all the excluded web parts within zone.
                  // A false value indicates the tabs will be placed BELOW all the excluded web parts within zone.
                  var tabsOnBottom = tabifyMeDiv.attr('data-location') == "bottom";
                  //hide the webpart containing the '.tabifyMe' div
                  $('#MSOZoneCell_WebPart' + tabsWebPartIDSuffix).hide();
                  //for all web parts inside the web part zone, put them into the WebPartDivIDs array excluding the web parts inside the excludedWebParts array
                  theZone.find('.ms-webpartzone-cell').each(function () { 
                     if($(this).attr('id') != 'MSOZoneCell_WebPart' + tabsWebPartIDSuffix &&
                     (($.inArray($(this).attr('id'),excludedWebParts)) < 0)) {
                  tabifyZone(theZone, WebPartDivIDs);
                  //Move the excluded webparts to above/below the tabs
                  if(tabsOnBottom) {
                     for (var i = excludedWebParts.length; i-- > 0; )
                        $('#' + excludedWebParts[i]).prependTo(theZone);
                  else {
                     for (i in excludedWebParts)
                        $('#' + excludedWebParts[i]).appendTo(theZone);            
      function tabifyZone(zone, webPartIDs) {
         zone.wrapInner(   "<div class='tabsContainer'>" + 
                        "<ul class='tabsContainerInner'></ul>" +
         for (index = webPartIDs.length - 1; index > -1; index--) {
            var title = webPartIDs[index];
            /*if($('#MSOZoneCell_WebPart' + title + '').length > 0)
            zone.find(".tabsContainerInner").prepend('<li><a href="#Tab' + title + '" id="TabHead' + title + '">' +
            $('span#WebPartTitle' + title + ' .ms-webpart-titleText').text() + '</a></li>');
            $('div#MSOZoneCell_WebPart' + title).wrap('<div class="TabContent" id=Tab' + title + '></div>');
            $('#WebPart' + title + '_ChromeTitle').remove();
         zone.find('.tabsContainer #' + $('.ui-tabs-active').attr('aria-controls')).show();
      <style type="text/css">
      .tabsContainer .ms-WPBorder {border:none;}
      .TabContent {margin-top:40px;}

      Note: As you can see, the script already references the jQuery and jQuery UI libraries.  If your current website already references them elsewhere, then lines 1 and 2 of this script can be omitted.

    2. Reference the file you created in Step 1 on your page so that the code runs.  You can do this in one of two ways:
      • Create a new Content Editor Web Part on your page that points to the file.  Please note that you must place this Content Editor Web Part in a separate zone from the one you wish to “tabify.”  This solution works best if you only wish to “tabify” web parts on this page, and nowhere else on your site. OR
      • Change the .txt file extension to a .js file and reference it on your master page.  This solution works best if you wish to “tabify” multiple pages within your site and don’t want to create Content Editor Web Parts referencing the script for every page.
    3. Create a new Content Editor Web Part in the same zone as the other web parts you wish to “tabify.”  This new CEWP should be located as the first web part in the zone.   This content CEWP would contain the following HTML code in it:
            <div class="tabifyMe"></div>

      For the sake of this example, we will call this div the .tabifyMe div.

    4. If there are web parts within the zone that you do not want to be included in the “tabify” process, simply list their web part titles inside the .tabifyMe div, in a comma-separated list.  Doing this will leave the listed web parts alone and not include them within the tabs
            <div class="tabifyMe">Images</div>
  1. If you are excluding web parts from being “tabified”, but would like these excluded web parts to be shown above the tabs, simply include the attribute data-location=bottom in the .tabifyMe div
          <div class="tabifyMe" data-location="bottom">Images</div>


Voilà!  I hope you enjoy making this work and feel free to leave a comment below!