Exercise 14 - Tabs
Exercise 14 - Tabs
Design a web page to use tabbed navigation for organizing the content
Use tab panes and organize the content into the panes
Facilitate navigation among the tab panes using the tabbed navigation
elements
Open the aboutus.html page and move to the second content row containing
the details of the corporate leadership of the restaurant.
Right after the Corporate Leadership heading, introduce the following code to
set up the tabbed navigation:
<li class="nav-item">
</li>
<li class="nav-item">
1
</li>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
</ul>
Note the use of the <ul> tag with the nav and nav-tabs classes to set up the tab
navigation. Each list item within the list acts as the tab element. Within each list
item, note that we set up the <a> tags with the href pointing to the id of the tab pane
of content to be introduced later. Also note that the <a> tag contains the data-
toggle=tab attribute. The first list element's <a> tag contains the class active. This
tab will be the open tab when we view the web page. We can switch to the other
tabs using the tabbed navigation that we just set up.
The details about the various corporate leaders should now be organized into
various tab panes. To begin this, we will enclose the entire content into a div
element with the class tab-content as specified below:
2
<div class="tab-content">
...
</div>
Then we take the name and description of the CEO of the company and
enclose it within a tab-pane as follows
</div>
Note the use of the tab-pane, fade, show, and active classes and with peter as the
id. This is the same id used as the href in the <a> link in the navigation.
The remaining content is also similarly enclosed inside appropriate divs with the
correct ids and the classes specified as above. Only the first tab pane will have
the show and active classes specified to indicate that the content should be
visible on the web page by default.
We now modify the CSS styles for the tab-content class in the mystyles.css file
as follows:
.tab-content {
3
border-bottom: 1px solid #ddd;
padding: 10px;
This modification adds a 1px border to the tab content which joins with the upper
border introduced by the tab navigation element to give a clean tab like
appearance.
Conclusions
In this exercise we learnt the use of tabbed navigation, tab content and tab panes
and their use in organizing and navigating within the content in a page.