Bootstrap provides an easy way to create predefined alert messages:
Alerts are produced with the .alert class, followed by one of the four contextual classes: .alert-success, .alert-info, .alert-warning, or .alert-danger.
Success! Indicates a successful or positive action.
Info! Indicates a neutral informative change or action.
Warning! Indicates a warning that might need attention.
Danger! Indicates a dangerous or potentially negative action.
Add the alert-link class to any links inside the alert box to produce “matching colored links”:
Success! You should read this message.
To close the alert message, include the .alert-dismissible class in the alert container. Then, add class=”close” and data-dismiss=”alert” to a link or button element (when clicked, the alert box disappears).
×
Success! Indicates a successful or positive action.
The aria-* attribute and × explanation
When developing a close button, use the aria-label=”close” attribute to increase accessibility for users who use screen readers.
The HTML entity × (×) is the preferred icon for close buttons, replacing the letter “x”.
Our HTML Entities Reference contains a complete list of all HTML Entities.
The .fade and .in classes create a fading effect when the alert message is closed.
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.