MoreLesson 191Free preview
Alerts
This lesson is part of How To · All levels
Summary
A warning is a short message that appears to inform the user of an event, such as a successful data storage or an error. JavaScript provides built-in blocking, but modern applications often use custom alert boxes to make their appearance consistent. The key to its creation is HTML elements, CSS styles, and class settings to display or hide messages.
Key points
- The browser's built-in interface temporarily stops interaction until the user presses OK
- Custom alerts are created from a regular HTML element and then displayed by adding a CSS class
- Use the role='alert' to automatically announce the message to the screen reader
- Set the shutdown button and don't display excessive alerts
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.