0
0
Bootsrapmarkup~20 mins

Toast notifications in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Toast Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What is the visual output of this Bootstrap toast code?
Look at the following Bootstrap toast HTML snippet. What will you see rendered in the browser?
Bootsrap
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
  <div class="toast-header">
    <strong class="me-auto">Notification</strong>
    <small>11 mins ago</small>
    <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  </div>
  <div class="toast-body">
    Hello, this is a toast message!
  </div>
</div>
AA full page alert covering the entire screen with the message 'Hello, this is a toast message!'.
BNothing visible because the toast requires JavaScript to show and the class 'show' is missing.
CA small popup box with a header 'Notification', a close button, a timestamp '11 mins ago', and the message 'Hello, this is a toast message!' visible on the page.
DOnly the text 'Hello, this is a toast message!' appears without any styling or close button.
Attempts:
2 left
💡 Hint
Check the class 'show' and the structure of the toast component.
📝 Syntax
intermediate
2:00remaining
Which option correctly initializes a Bootstrap toast with JavaScript?
You want to show a Bootstrap toast using JavaScript. Which code snippet correctly creates and shows the toast?
Bootsrap
const toastEl = document.getElementById('myToast');
Aconst toast = new bootstrap.Toast(toastEl); toast.show();
Bconst toast = bootstrap.toast(toastEl); toast.display();
Cconst toast = new Toast(toastEl); toast.show();
Dconst toast = bootstrap.Toast(toastEl); toast.show();
Attempts:
2 left
💡 Hint
Bootstrap's JavaScript API uses 'new bootstrap.Toast(element)'.
accessibility
advanced
2:00remaining
Which ARIA attributes make Bootstrap toasts accessible?
Bootstrap toasts use ARIA attributes to help screen readers. Which set of attributes is correct for a toast container?
Arole="dialog" aria-modal="true" aria-hidden="false"
Brole="alert" aria-live="assertive" aria-atomic="true"
Crole="status" aria-live="polite" aria-atomic="false"
Drole="alertdialog" aria-live="off" aria-atomic="true"
Attempts:
2 left
💡 Hint
Toasts announce messages immediately and fully to assistive tech.
layout
advanced
2:00remaining
How to position multiple Bootstrap toasts stacked at the bottom right corner?
You want multiple toasts stacked vertically at the bottom right corner of the screen. Which CSS and HTML setup achieves this?
Bootsrap
<div id="toastContainer" aria-live="polite" aria-atomic="true" class="position-fixed bottom-0 end-0 p-3">
  <!-- Toasts go here -->
</div>
AUse a container with 'position-absolute top-50 start-50 translate-middle' and place toasts inside it.
BUse a container with 'position-relative top-0 start-0 m-3' and place toasts inside it.
CPlace toasts directly in body without container and add 'float-right' class to each toast.
DUse a container with classes 'position-fixed bottom-0 end-0 p-3' and place toasts inside it.
Attempts:
2 left
💡 Hint
Bootstrap utilities for fixed positioning and padding help place toasts.
🧠 Conceptual
expert
3:00remaining
What happens if you omit the 'aria-atomic' attribute on a Bootstrap toast?
Consider a toast with role="alert" and aria-live="assertive" but no aria-atomic attribute. What is the likely effect on screen readers?
AScreen readers may read only parts of the toast message, causing incomplete announcements.
BThe toast will not be announced at all by screen readers.
CThe toast message will be announced multiple times causing repetition.
DThere is no effect; aria-atomic is optional and ignored.
Attempts:
2 left
💡 Hint
aria-atomic controls whether the entire region is read or only changed parts.