Bootstrap 5.3 Modal
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap 5.3 Modal Example</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Bootstrap 5.3 Modal Example</h2>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">
Open Modal
</button>
<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">Modal Title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>This is the modal content.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Code Output
Bootstrap 5.3 Modal Example
Modal Title
This is the modal content.
Modal
Modal in Bootstrap is a component that displays content in a layered dialog box on top of the main page. It is commonly used to show additional information. The modal can be triggered by clicking a button or a link.
-
- Use the
modal
class along with the necessary markup and attributes. -
data-bs-toggle
attribute is used to toggle the visibility of the modal -
data-bs-target
attribute specifies the target modal element data-bs-dismiss
to enable closing the modal by clicking outside or on a close button.
- Use the