Creating Tabbed Navigation Interfaces

Tutorial 4 of 5

1. Introduction

Goal of the Tutorial

In this tutorial, we will create a tabbed navigation interface using HTML and Bootstrap. Tabbed navigation is an effective way to display multiple related content in a single view, improving user experience.

What You Will Learn

You will learn how to:
- Construct a basic HTML layout
- Implement Bootstrap
- Create a tabbed navigation interface

Prerequisites

Basic knowledge of HTML and CSS is required. Familiarity with Bootstrap would be beneficial.

2. Step-by-Step Guide

Basic HTML Layout

We'll start by creating a simple HTML layout with the <!DOCTYPE html> declaration, a element, a element, and a element.

Implementing Bootstrap

Bootstrap is a powerful front-end framework that can help you design websites faster and easier. It includes HTML and CSS based design templates for typography, forms, buttons, tables, navigation, modals, image carousels, and many other, as well as optional JavaScript plugins.

You can include Bootstrap in your project by linking to the Bootstrap CDN in the section of your HTML file.

Creating a Tabbed Navigation Interface

To create a tabbed navigation interface, we will use the Bootstrap's tabs component. Each tab's label will be in a

  • element and the content for each tab will be in a
    element.

    3. Code Examples

    Here's a simple example of a tabbed navigation interface:

    <!DOCTYPE html>
    <html>
    <head>
        <!-- Link to Bootstrap CSS -->
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
            <!-- Navigation Tabs -->
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link active" href="#home" data-toggle="tab">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#profile" data-toggle="tab">Profile</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#messages" data-toggle="tab">Messages</a>
                </li>
            </ul>
    
            <!-- Tab Content -->
            <div class="tab-content">
                <div class="tab-pane active" id="home">This is the Home tab.</div>
                <div class="tab-pane" id="profile">This is the Profile tab.</div>
                <div class="tab-pane" id="messages">This is the Messages tab.</div>
            </div>
        </div>
    
        <!-- Link to Bootstrap JS and its dependencies -->
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    </body>
    </html>
    

    In this example, we have three tabs: Home, Profile, and Messages. Each tab is linked to its corresponding content using the href attribute and the data-toggle="tab" attribute. The class "active" is added to the first tab to make it the default active tab.

    4. Summary

    In this tutorial, you've learned how to:
    - Create a basic HTML layout
    - Implement Bootstrap in your project
    - Design a tabbed navigation interface using Bootstrap

    For further learning, you can explore more about Bootstrap components and utilities.

    5. Practice Exercises

    1. Create a tabbed navigation interface with five tabs.

    2. Add an icon to each tab using Bootstrap's icon classes.

    3. Make the second tab the default active tab.

    Solutions:

    1. You can simply copy the

    2. element and the
      element from the example above and change the href attribute, the text content, and the id attribute accordingly.

    3. To add an icon, you can add a element with the relevant Bootstrap icon class inside the element. For example:

    <a class="nav-link" href="#home" data-toggle="tab">
        <i class="fas fa-home"></i> Home
    </a>
    
    1. To make the second tab the default active tab, remove the "active" class from the first tab and add it to the second tab.

    Remember, practice is the key to mastering any skill, so make sure to practice these exercises to become proficient in creating tabbed navigation interfaces.

  • CodiWiki

    A comprehensive platform offering professional web development services, interactive tutorials, and powerful development tools.

    © 2025 CodiWiki. All rights reserved.

    Stay Updated

    Subscribe to our newsletter for the latest tutorials, tools, and coding tips.