Provide contextual feedback messages for typical user actions using flexible alert messages.

Alerts may contain text or other elements and are styled according to their required contextual class,.alert-{color}, where color is any color from the color palette. An optional dismiss button allows the user to dismiss the alert.

<div class="alert alert-primary" role="alert">
  I'm a primary alert, check me out!
<div class="alert alert-secondary" role="alert">
  I'm a secondary alert, check me out!
<div class="alert alert-success" role="alert">
  I'm a success alert, check me out!
<div class="alert alert-danger" role="alert">
  I'm a danger alert, check me out!
<div class="alert alert-warning" role="alert">
  I'm a warning alert, check me out!
<div class="alert alert-info" role="alert">
  I'm a info alert, check me out!
<div class="alert alert-light" role="alert">
  I'm a light alert, check me out!
<div class="alert alert-dark" role="alert">
  I'm a dark alert, check me out!

Customizing alerts

Style links to fit in with the alert using .alert-link.

<div class="alert alert-warning" role="alert">
  I'm a warning alert. <a href="" class="alert-link">Click here to learn more.</a>

Additional content

Alerts can also contain additional HTML elements like headings, paragraphs and dividers.

<div class="alert alert-success" role="alert">
  <h4 class="alert-heading">Well done!</h4>
  <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
  <p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>


Using the alert plugin from the Bootstrap JavaScript, it’s possible to dismiss any alert inline. Here’s how:

  • Add the .alert-dismissible class to your alert.
  • Add a dismiss button with the .close class and the data-dismiss="alert" attribute.
  • To animate alerts when dismissing them, add .fade and .show classes to the alert.

<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>

Javascript behavior


Enable dismissal of an alert via JavaScript



Method Description
$().alert() Makes an alert listen for click events on descendant elements which have the data-dismiss="alert" attribute. (Not necessary when using the data-api’s auto-initialization.)
$().alert('close') Closes an alert by removing it from the DOM. If the .fade and .show classes are present on the element, the alert will fade out before it is removed.
$().alert('dispose') Destroys an element’s alert.


Bootstrap’s alert plugin exposes a few events for hooking into alert functionality.

Event Description This event fires immediately when the close instance method is called. This event is fired when the alert has been closed (will wait for CSS transitions to complete).

$('#myAlert').on('', function () {
  // do something…