Skip to content
Related Articles
Open in App
Not now

Related Articles

How to create a basic Modal component in Bootstrap ?

Improve Article
Save Article
  • Last Updated : 04 Oct, 2021
Improve Article
Save Article

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">


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!