Bootstrap 4 Tabs Horizontal Example

Bootstrap 4 tabs with horizontal navs example. In bootstrap 4 tabs we have added font-awesome icons to make the toggleable navbar more attractive for better UI/UX layout.

Add HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <title>How To create Bootstrap 4 Tabs Horizontal Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
    <!-- Horizontal Bootstrap 4 Tabs -->
    <section id="tab-menus">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <h2 class="text-center mt-4 mb-5">Bootstrap 4 Tabs</h2>
                    <!-- Tabs navs -->
                    <ul class="nav nav-tabs" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" data-toggle="tab" href="#firstMenu"><i class="fab fa-html5"></i> HTML5</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#secondmenu"><i class="fab fa-wordpress"></i> WordPress</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#thirdmenu"><i class="fab fa-bootstrap"></i> Bootstrap</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#fourthmenu"><i class="fab fa-angular"></i> Angular</a>
                        </li>
                    </ul>
                     <!-- Tabs Content -->
                    <div class="tab-content">
                        <div id="firstMenu" class="tab-pane active">
                            <h3 class="mt-4">What do you think about HTML5?</h3>
                            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries</p>
                        </div>
                        <div id="secondmenu" class="tab-pane">
                            <h3 class="mt-4">What do you think about WordPress?</h3>
                            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English.</p>
                        </div>
                        <div id="thirdmenu" class="tab-pane">
                            <h3 class="mt-4">What do you think about Bootstrap?</h3>
                            <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites</p>
                        </div>
                        <div id="fourthmenu" class="tab-pane">
                            <h3 class="mt-4">What do you think about Angular JS?</h3>
                            <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</body>
</html>

Add CSS

<style>
#tab-menus {
    padding: 30px 0px;
}
#tab-menus .nav-tabs {
    background-color: #f3f3f3;
    box-shadow: 0px 0px 33px -15px #000;
}
#tab-menus .tab-content {
    background-color: #f3f3f3;
    padding: 5px 15px;
}
#tab-menus .nav-link {
    font-size: 18px;
    color: #9C27B0;
}
#tab-menus .nav-tabs {
    border-bottom: 1px solid #9C27B0;
}
#tab-menus .nav-tabs .nav-link.active {
    border-color: #9C27B0 #9C27B0 #fff;
}
</style>

Leave a Comment