Bootstrap 5 provides an easy way to create predefined alert messages.
Alerts are created with the .alert class, followed by one of the contextual classes.
.alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, etc.
To close the alert message, add a .alert-dismissible class to the alert container. Then add class="btn-close" and data-bs-dismiss="alert" to a button or link.
Edit the code below and click Run to see the result live.