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.
<div class="alert">
<button type="button" class="close" data-dismiss="alert">×</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">×</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">×</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">×</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
<div class="alert alert-error">
...
</div>
Success: .alert-success
<div class="alert alert-success">
...
</div>
Information: .alert-info
<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.