We often see certain alerts on some websites before or after completing an action. These alert messages are highlighted texts that are important to take in consideration while performing a process. Bootstrap allows showing these alert messages on the website using predefined classes.
The .alert class followed by contextual classes are used to display the alert message on website. The alert classes are: .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light and .alert-dark.
<div class="alert> Contents... <div>
Closing Alerts: The .alert-dismissible class is used within .container class to close the alert message. Then use class=”close” and data-dismiss=”alert” to link a button element.
<div class="alert alert_type alert-dismissible"> <button type="button" class="close" data-dismiss="alert">x</button> Alert message <div>
Animated Alerts: The .fade and .show classes are used to add the fading effect of animation when closing the alert message.
<div class="alert alert_type alert-dismissible fade show"> <button type="button" class="close" data-dismiss="alert">x</button> Alert message <div>
- How to Automatically Close Alerts using Twitter Bootstrap ?
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Include Bootstrap in AngularJS using ng-bootstrap
- Difference between bootstrap.css and bootstrap-theme.css
- Difference Between Bootstrap 3 and Bootstrap 4
- Difference between Bootstrap 4 and Bootstrap 5
- What's new in Bootstrap v4.3 ?
- Bootstrap 4 | Spinners
- Bootstrap 4 | Jumbotron
- Bootstrap 4 | Badges
- Bootstrap 4 | Cards
- Bootstrap 4 | Images
- Bootstrap 4 | Tables
- Bootstrap 4 | Dropdowns
- Bootstrap 4 | Introduction
- Bootstrap 4 | Typography
- Bootstrap 4 | Scrollspy
- Bootstrap 4 | Navigation Bar
- Bootstrap 4 | Colors
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.