Answer: Create an alert with a div that has the class alert plus a colour class such as alert-success, alert-danger or alert-warning.
<div class="alert alert-success" role="alert">
Your form was submitted successfully!
</div>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Warning!</strong> Please check your input.
<button type="button" class="btn-close" data-bs-dismiss="alert"
aria-label="Close"></button>
</div>.alertgives the box its padding and border; the contextual class sets the colour:alert-primary,alert-secondary,alert-success,alert-danger,alert-warning,alert-info,alert-light,alert-dark.role="alert"helps screen readers.- To let the user close it, add
alert-dismissible fade showand a close button. The example uses Bootstrap 5 (btn-close,data-bs-dismiss). In Bootstrap 4 the button is<button type="button" class="close" data-dismiss="alert">×</button>. Dismissing needs Bootstrap's JavaScript to be included. - Use
.alert-linkon links inside an alert to match its colour.