Tabs allow you to display data in different pages, each one with a tab title on top of it. Tabs are perfect for scenarios when you have a lot of data to display, but the user only needs it in smaller chunks, displayed one at a time. One key thing to remember about using tabs is they are restricting the user’s ability to scroll.
In order to create the tabs section, you need to create an unordered list of links, similar to a list of links displayed in navbar. You need to decorate the ul element with the nav and nav-tabs classes, and set the roleas tablist.
- <ulclass=”nav nav-tabs” role=”tablist”>
- <!– tab links –>
The links need role=’tab’ and data-toggle=’tab’ set on them. In additon, the href attribute needs to be set to the ID of the container of the content you wish to display on that tab. For example, if the div that contains the data to display has an ID of Demo, you need to set the href of the link to be #Demo. Note again that when you target content for Bootstrap, you need to use the CSS selector syntax. In addition, you add active to the first one.
- <liclass=”active”><a href=”#tabs-first” role=”tab” data-toggle=”tab”>First</a></li>
- <li><ahref=”#tabs-second” role=”tab” data-toggle=”tab”>Second</a></li>
The tab content is placed below the tabs, and inside of a containing div element with the tab-content class.