Alerts

Use alert messages to clearly communicate warnings, confirmations and helpful information. Start with the basic .alert pattern, then choose a contextual class when the message needs a distinct meaning.

Basic alert example

Wrap the message in an element with the .alert class. Add a dismiss button when visitors should be able to close the notice.

Warning! Please review this message before continuing.
<div class="alert">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Warning!</strong> Please review this message before continuing.
</div>

Make an alert dismissible

Use data-dismiss="alert" on the close control. If you use an <a> element, Mobile Safari and Mobile Opera also require href="#" for alert dismissal.

<a href="#" class="close" data-dismiss="alert">&times;</a>

A <button> is also an option. Include type="button" so the control does not submit a form.

<button type="button" class="close" data-dismiss="alert">&times;</button>

For JavaScript-based dismissal, use the alerts jQuery plugin.

Use an extended alert for longer messages

Add .alert-block when an alert needs more room above and below the message, such as when it includes a heading and supporting details.

Warning!

Please review the information below before continuing.

<div class="alert alert-block">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <h4>Warning!</h4>
  Please review the information below before continuing.
</div>

Choose a contextual alert class

Add an optional class to communicate the purpose of the message more clearly.

Error or danger: .alert-error

Please check the form. Update the highlighted information and try submitting again.
<div class="alert alert-error">
  ...
</div>

Success: .alert-success

Well done! Your message has been acknowledged.
<div class="alert alert-success">
  ...
</div>

Information: .alert-info

Heads up! This message may need your attention.
<div class="alert alert-info">
  ...
</div>

Alert FAQs

What class creates a basic alert?

Apply the .alert class to the element that contains the alert message.

How do I add a close button to an alert?

Add a close control with data-dismiss="alert". When using a button, include type="button".

When should I use .alert-block?

Use .alert-block for longer notices that benefit from additional vertical padding, such as messages with a heading and paragraph.

Which classes are available for contextual alerts?

The available contextual examples are .alert-error, .alert-success and .alert-info.

Back to Top
Product has been added to your cart
Compare (0)