0
0
Bootsrapmarkup~20 mins

Dismissible alerts in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dismissible Alert 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 dismissible alert?
Look at the following HTML code using Bootstrap 5. What will you see in the browser?
Bootsrap
<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Warning!</strong> This is a dismissible alert.
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
AA yellow alert box with no close button visible.
BA red alert box with bold text 'Warning!' and a close button that does nothing when clicked.
CA yellow alert box with bold text 'Warning!' and a close button on the right side that can hide the alert when clicked.
DA green alert box with bold text 'Warning!' and a close button that reloads the page when clicked.
Attempts:
2 left
💡 Hint
Remember that 'alert-warning' gives a yellow background and 'btn-close' creates a functional close button.
📝 Syntax
intermediate
2:00remaining
Which option correctly adds a dismissible alert with a close button in Bootstrap 5?
Choose the correct HTML snippet that creates a dismissible alert with a close button that works.
A
&lt;div class="alert alert-info alert-dismissible fade show" role="alert"&gt;
  Info alert.
  &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;
&lt;/div&gt;
B
&lt;div class="alert alert-info alert-dismissible fade show" role="alert"&gt;
  Info alert.
  &lt;button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;
&lt;/div&gt;
C
&lt;div class="alert alert-info alert-dismissible fade show" role="alert"&gt;
  Info alert.
  &lt;button type="button" class="btn-close" aria-label="Close"&gt;&lt;/button&gt;
&lt;/div&gt;
D
&lt;div class="alert alert-info alert-dismissible fade show" role="alert"&gt;
  Info alert.
  &lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;
&lt;/div&gt;
Attempts:
2 left
💡 Hint
Bootstrap 5 uses 'btn-close' and 'data-bs-dismiss' attributes for dismissible alerts.
accessibility
advanced
2:00remaining
Which attribute improves accessibility for the dismiss button in a Bootstrap alert?
What attribute should be added to the close button to help screen readers understand its purpose?
Aaria-hidden="true"
Baria-label="Close"
Crole="button"
Dtabindex="-1"
Attempts:
2 left
💡 Hint
Think about what label a screen reader needs to announce the button's function.
selector
advanced
2:00remaining
Which CSS selector targets only the close button inside a Bootstrap dismissible alert?
Choose the CSS selector that selects the close button inside alerts with class 'alert-dismissible'.
A.alert-dismissible .btn-close
B.alert-dismissible > .btn-close
C.btn-close.alert-dismissible
Dbutton.btn-close.alert-dismissible
Attempts:
2 left
💡 Hint
Remember the difference between direct child (>) and any descendant (space).
🧠 Conceptual
expert
2:00remaining
What happens if you omit the 'data-bs-dismiss="alert"' attribute on the close button in a Bootstrap dismissible alert?
Consider a dismissible alert with a close button that lacks the 'data-bs-dismiss="alert"' attribute. What is the result when the button is clicked?
AThe alert will close but with a delay of 5 seconds.
BThe alert will close normally because the button's class 'btn-close' is enough to trigger dismissal.
CClicking the button will reload the page because the attribute is missing.
DThe alert will not close because Bootstrap's JavaScript listens for 'data-bs-dismiss="alert"' to trigger hiding.
Attempts:
2 left
💡 Hint
Bootstrap's JavaScript uses specific attributes to know which elements trigger actions.