Bootstrap icons use the tag with classes starting with 'bi bi-'.
✗ Incorrect
Option D correctly places the Bootstrap icon element with classes 'bi bi-search' before the button text. Option D places the icon after the text, which is valid but does not match the prompt. Option D uses a non-existent class 'icon-search'. Option D uses an empty tag without content, so no icon appears.
📝 Syntax
intermediate
2:00remaining
Correct syntax for input with icon using Bootstrap
Which option correctly adds a Bootstrap icon inside an input group on the left side?
Bootstrap input groups use 'input-group-text' for addon elements.
✗ Incorrect
Option A uses the correct Bootstrap class 'input-group-text' to wrap the icon and places it before the input, which is the standard pattern. Option A places the icon after the input, which is valid but does not match the prompt. Options C and D use invalid classes 'input-group-icon' and 'input-icon' which do not exist in Bootstrap.
❓ selector
advanced
2:00remaining
CSS selector to style only icons inside buttons
Which CSS selector will apply styles only to Bootstrap icons inside buttons but not icons elsewhere?
Abutton i.bi { color: red; }
B.btn > i.bi { color: red; }
Ci.bi.btn { color: red; }
Dbutton .bi { color: red; }
Attempts:
2 left
💡 Hint
Use direct child selector to target icons directly inside buttons with class 'btn'.
✗ Incorrect
Option B uses '.btn > i.bi' which selects elements with class 'bi' that are direct children of elements with class 'btn' (Bootstrap buttons). Option B selects any with class 'bi' inside any
❓ layout
advanced
2:00remaining
Aligning icon and text vertically centered in a Bootstrap button
Which CSS snippet ensures the icon and text inside a Bootstrap button are vertically centered and spaced nicely?
Use vertical-align and margin to align inline icons with text.
✗ Incorrect
Option C uses 'vertical-align: middle' to align the icon vertically with the text and adds right margin for spacing. Option C makes the icon block-level and adds bottom margin, which stacks icon above text. Option C floats the icon left, which can break button layout. Option C uses absolute positioning, which removes the icon from normal flow and can overlap text.
❓ accessibility
expert
3:00remaining
Accessible icon usage in buttons
Which option correctly adds accessible text for a Bootstrap button with only an icon (no visible text)?
Use aria-label on the button and aria-hidden on the icon for screen readers.
✗ Incorrect
Option A correctly adds 'aria-label' on the button to provide accessible text and marks the icon as 'aria-hidden' so screen readers ignore the decorative icon. Option A uses 'title' on the icon, which is not reliable for accessibility. Option A incorrectly adds 'aria-label' on the icon instead of the button. Option A hides the button from screen readers, making it inaccessible.
Practice
(1/5)
1. What is the main purpose of adding icons inside Bootstrap buttons or inputs?
easy
A. To increase the size of buttons automatically
B. To make buttons and inputs easier to understand visually
C. To change the button color to blue
D. To disable the input field
Verify
Solution
Step 1: Understand the role of icons in UI
Icons provide visual clues that help users quickly understand the purpose of buttons or inputs.
Step 2: Relate to Bootstrap usage
Bootstrap uses icons to improve user experience by making controls more intuitive.
Final Answer:
To make buttons and inputs easier to understand visually -> Option B
Quick Check:
Icons improve clarity = A [OK]
Hint: Icons help users recognize actions quickly [OK]
Common Mistakes:
Thinking icons change button size automatically
Assuming icons change colors by default
Believing icons disable inputs
2. Which is the correct way to add a Bootstrap icon inside a button?
easy
A. Search
B. Search
C. Search
D. Search
Verify
Solution
Step 1: Identify Bootstrap icon syntax
Bootstrap icons use <i> tags with classes like "bi bi-search".
Step 2: Check each option
<button><i class="bi bi-search"></i> Search</button> uses <i> with correct classes; others use wrong tags or methods.
Final Answer:
<button><i class="bi bi-search"></i> Search</button> -> Option D
Quick Check:
Bootstrap icons use <i> + bi classes = A [OK]
Hint: Use <i> tag with 'bi' classes for Bootstrap icons [OK]