Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to create a basic Modal component in Bootstrap ?

  • Last Updated : 04 Oct, 2021

Modals are JavaScript pop-ups that help us to deliver very useful content in the website like displaying save, delete, download or close confirmation on the website. Bootstrap modals are lightweight and multipurpose JavaScript components. They are also customizable and responsive components. In this article, we will learn about how to create a basic modal component using the bootstrap framework.

For that first, we have to import the following bootstrap CDN in our HTML file. 

<!– Bootstrap CSS –>
<link href=”” rel=”stylesheet” integrity=”sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU” crossorigin=”anonymous”>

<!– Bootstrap JS –>
<script src=”” integrity=”sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ” crossorigin=”anonymous”></script>

Example: In this example, we will see how to create a basic modal using the Bootstrap modal component.


<!doctype html>
<html lang="en">
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1">
    <!-- Bootstrap CSS -->
    <link href=
        rel="stylesheet" integrity=
    <script src=
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-primary" 
        style="margin: 2em;">
        Demo Modal
    <!-- Modal -->
    <div class="modal fade" id="exampleModal" 
        tabindex="-1" aria-labelledby="exampleModalLabel" 
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" 
                        This is sample title.
                    <button type="button" class="btn-close" 
                <div class="modal-body">
                    This is the body of the modal.
                <div class="modal-footer">
                    <button type="button" 
                        class="btn btn-secondary" 
                    <button type="button" 
                        class="btn btn-primary">


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!