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>
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Include Bootstrap in AngularJS using ng-bootstrap
- Difference between bootstrap.css and bootstrap-theme.css
- What's new in Bootstrap v4.3 ?
- Bootstrap 4 | Badges
- Bootstrap | Tables | Set-1
- Bootstrap 4 | Nav-pills
- Bootstrap | Tables | Set-2
- Bootstrap 4 | Panels
- Bootstrap 4 | Wells
- Bootstrap 4 | Cards
- Bootstrap | Spinners Set-1
- Typography in Bootstrap
- Clearfix in Bootstrap
- Bootstrap | Spinners Set-2
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.