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
- How to Automatically Close Alerts using Twitter Bootstrap ?
- Bootstrap 5 Alerts
- 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
- Beginning BootStrap (Part-1) | Introduction and Installation
- Beginning BootStrap (Part-2) | Grid System
- Bootstrap (Part-3) | Buttons, Glyphicons, Tables
- Bootstrap (Part-5) | DropDowns and Responsive Tabs
- Bootstrap (Part-4) | Vertical Forms, Horizontal Forms, Inline Forms
- How to get circular buttons in bootstrap 4 ?
- Bootstrap (Part-6) | Progress Bar and Jumbotron
- Bootstrap (Part-8) | Badges, Labels, Page Headers
- Bootstrap (Part-9) | Tooltips
- Bootstrap | Navigation Bar
- Bootstrap | Carousel
- Bootstrap | Cards
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.