Challenge - 5 Problems
Bootstrap Close Button Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What is the visual output of this Bootstrap close button code?
Look at the following HTML code using Bootstrap 5. What will you see in the browser?
Bootsrap
<button type="button" class="btn-close" aria-label="Close"></button>
Attempts:
2 left
💡 Hint
Bootstrap's close button uses a small icon with no text by default.
✗ Incorrect
The Bootstrap 'btn-close' class creates a small button with an 'X' icon for closing dialogs or alerts. It does not show any text.
❓ accessibility
intermediate2:00remaining
Which attribute ensures the close button is accessible to screen readers?
Given a Bootstrap close button, which attribute helps screen readers understand its purpose?
Bootsrap
<button type="button" class="btn-close" ???></button>
Attempts:
2 left
💡 Hint
Screen readers use aria-label to describe buttons without visible text.
✗ Incorrect
The aria-label attribute provides an accessible name for the button, so screen readers announce it as 'Close'.
📝 Syntax
advanced2:00remaining
What error occurs with this close button code?
Identify the error in this Bootstrap close button code snippet:
Bootsrap
<button type="button" class="btn-close" aria-label="Close"></button>
Attempts:
2 left
💡 Hint
Check if all HTML tags are properly opened and closed.
✗ Incorrect
The closing tag '' is invalid because 'btn' is not a valid HTML tag. The button is self-closed with ''.
❓ layout
advanced2:00remaining
How to position a Bootstrap close button at the top-right corner of a modal?
Which CSS class combination correctly places the close button at the top-right inside a Bootstrap modal header?
Bootsrap
<div class="modal-header"> <h5 class="modal-title">Modal title</h5> <button type="button" class="???" aria-label="Close"></button> </div>
Attempts:
2 left
💡 Hint
Use margin utilities to push the button to the right.
✗ Incorrect
The 'ms-auto' class adds left margin auto, pushing the button to the right side inside a flex container like modal-header.
🧠 Conceptual
expert3:00remaining
What happens if you omit the aria-label on a Bootstrap close button?
Consider a close button with class 'btn-close' but no aria-label attribute. What is the impact on accessibility?
Bootsrap
<button type="button" class="btn-close"></button>
Attempts:
2 left
💡 Hint
Think about how screen readers identify buttons without visible text.
✗ Incorrect
Without aria-label, screen readers have no descriptive text for the button, so users may not understand its function.