Challenge - 5 Problems
SVG Icon Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediateWhat is the visual output of this Bootstrap SVG icon usage?
Given the following HTML snippet using Bootstrap icons, what will you see rendered in the browser?
Bootsrap
<svg class="bi" width="2rem" height="2rem" fill="currentColor"> <use xlink:href="#alarm"/> </svg> <svg xmlns="http://www.w3.org/2000/svg" style="display:none;"> <symbol id="alarm" viewBox="0 0 16 16"> <path d="M8 16a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/> </symbol> </svg>
Attempts:
2 left
💡 Hint
Remember that elements inside an SVG with display:none can be referenced by
✗ Incorrect
The
📝 Syntax
intermediateWhich option correctly uses a Bootstrap SVG icon with accessibility?
Select the code snippet that correctly includes an SVG icon with proper accessibility attributes for screen readers.
Attempts:
2 left
💡 Hint
Screen readers need a role and a descriptive label to understand icons.
✗ Incorrect
Option D uses role="img" and aria-label="Search icon" which provides a meaningful description for screen readers. Other options either hide the icon or lack descriptive labels.
❓ selector
advancedWhich CSS selector targets only Bootstrap SVG icons with the class 'bi' inside buttons?
Choose the CSS selector that applies styles only to SVG elements with class 'bi' that are direct children of
Attempts:
2 left
💡 Hint
The '>' selector means direct child, while a space means any descendant.
✗ Incorrect
Option A selects SVG elements with class 'bi' that are direct children of button elements. Option A selects any descendant SVG.bi inside button, which is broader. Options C and D are invalid for the requirement.
❓ layout
advancedHow to center a Bootstrap SVG icon horizontally and vertically inside a fixed-size button using Flexbox?
Given a button with fixed width and height, which CSS snippet correctly centers the SVG icon inside it?
Attempts:
2 left
💡 Hint
Flexbox is great for centering both horizontally and vertically.
✗ Incorrect
Option C uses flexbox properties to center content horizontally and vertically. Option C only affects inline text alignment, C centers block elements horizontally but not vertically, and D moves the button itself, not the icon inside.
🧠 Conceptual
expertWhat is the main advantage of using with
Why does Bootstrap recommend defining icons inside elements and referencing them with
Attempts:
2 left
💡 Hint
Think about code repetition and loading speed.
✗ Incorrect
Using with
