Bird
Raised Fist0
Bootsrapmarkup~20 mins

Input groups in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Input Group Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What will this Bootstrap input group render?
Look at the following Bootstrap input group code. What will you see in the browser?
Bootsrap
<div class="input-group mb-3">
  <span class="input-group-text" id="basic-addon1">@</span>
  <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
AAn input box with '@' text inside the input box as placeholder.
BA plain input box with '@' text above it.
CAn input box with '@' text on the right side outside the input border.
DAn input box with a grey box containing '@' on the left side inside the input border.
Attempts:
2 left
💡 Hint
Remember that adds a styled box inside the input group.
❓ selector
intermediate
1:30remaining
Which class adds a button inside a Bootstrap input group?
You want to add a clickable button inside a Bootstrap input group. Which class should you use on the button element?
Abtn
Binput-group-text
Cbtn-group
Dinput-group-btn
Attempts:
2 left
💡 Hint
Bootstrap buttons always use the 'btn' class.
🧠 Conceptual
advanced
1:30remaining
What is the purpose of aria-describedby in Bootstrap input groups?
In Bootstrap input groups, the input often has an attribute like aria-describedby="basic-addon1". What does this attribute do?
AIt links the input to a descriptive element for screen readers, improving accessibility.
BIt styles the input border color when focused.
CIt makes the input required before form submission.
DIt disables the input field.
Attempts:
2 left
💡 Hint
Think about how screen readers understand form controls.
❓ layout
advanced
2:00remaining
How to place a button on the right side inside a Bootstrap input group?
You want a text input with a button attached on the right side inside the same input group. Which code snippet achieves this?
A
&lt;div class="input-group"&gt;
  &lt;span class="input-group-text"&gt;Go&lt;/span&gt;
  &lt;input type="text" class="form-control"&gt;
&lt;/div&gt;
B
&lt;div class="input-group"&gt;
  &lt;button class="btn btn-primary" type="button"&gt;Go&lt;/button&gt;
  &lt;input type="text" class="form-control"&gt;
&lt;/div&gt;
C
&lt;div class="input-group"&gt;
  &lt;input type="text" class="form-control"&gt;
  &lt;button class="btn btn-primary" type="button"&gt;Go&lt;/button&gt;
&lt;/div&gt;
D
&lt;div class="input-group"&gt;
  &lt;input type="text" class="form-control"&gt;
  &lt;span class="input-group-text"&gt;Go&lt;/span&gt;
&lt;/div&gt;
Attempts:
2 left
💡 Hint
The order of elements inside input-group determines their position.
❓ accessibility
expert
2:30remaining
Which attribute is essential for screen reader users to understand input groups with multiple addons?
When an input group has multiple addons (like prefix and suffix text), which attribute should be used on the input to ensure screen readers read all descriptions correctly?
Aaria-labelledby with IDs of all addon elements
Baria-describedby with IDs of all addon elements separated by spaces
Caria-label with a combined text description
Daria-hidden on all addon elements
Attempts:
2 left
💡 Hint
aria-describedby can reference multiple elements by listing their IDs separated by spaces.

Practice

(1/5)
1. What is the main purpose of Bootstrap input groups?
easy
A. To add text, symbols, or buttons next to input fields
B. To create dropdown menus
C. To style tables with borders
D. To add animations to buttons

Solution

  1. Step 1: Understand input groups concept

    Input groups in Bootstrap are used to add extra elements like text or buttons next to input fields to improve clarity and interaction.
  2. Step 2: Identify the correct purpose

    Options A, C, and D describe other Bootstrap features unrelated to input groups.
  3. Final Answer:

    To add text, symbols, or buttons next to input fields -> Option A
  4. Quick Check:

    Input groups add elements next to inputs = B [OK]
Hint: Input groups add stuff beside inputs, not menus or tables [OK]
Common Mistakes:
  • Confusing input groups with dropdown menus
  • Thinking input groups style tables
  • Assuming input groups add animations
2. Which Bootstrap class is used to create an input group container?
easy
A. btn-group
B. input-group
C. form-control
D. input-container

Solution

  1. Step 1: Recall Bootstrap input group structure

    The container for input groups uses the class input-group to wrap inputs and addons.
  2. Step 2: Differentiate from other classes

    form-control styles inputs, btn-group groups buttons, and input-container is not a Bootstrap class.
  3. Final Answer:

    input-group -> Option B
  4. Quick Check:

    Container class for input groups = input-group [OK]
Hint: Remember: input-group wraps inputs and addons [OK]
Common Mistakes:
  • Using form-control as container instead of input-group
  • Confusing btn-group with input-group
  • Using non-existent class input-container
3. What will this Bootstrap input group render?
<div class="input-group">
  <span class="input-group-text">@</span>
  <input type="text" class="form-control" placeholder="Username" />
</div>
medium
A. An input box with '@' as placeholder text
B. A button labeled '@' next to an input box
C. An input box with '@' symbol on the left inside a gray box
D. A plain input box with no extra elements

Solution

  1. Step 1: Analyze the input group structure

    The input-group-text inside the input-group adds a styled box with '@' before the input field.
  2. Step 2: Understand rendering result

    The '@' appears inside a gray box on the left side of the input box, not as a button or placeholder.
  3. Final Answer:

    An input box with '@' symbol on the left inside a gray box -> Option C
  4. Quick Check:

    input-group-text adds symbol box next to input = A [OK]
Hint: input-group-text adds styled text inside input group [OK]
Common Mistakes:
  • Thinking input-group-text creates a button
  • Confusing placeholder with input-group-text content
  • Ignoring the gray box styling around '@'
4. Identify the error in this Bootstrap input group code:
<div class="input-group">
  <input type="text" class="form-control" placeholder="Email" />
  <span class="input-group-btn">
    <button class="btn btn-primary" type="button">Send</button>
  </span>
</div>
medium
A. The class 'input-group-btn' is deprecated and should be replaced
B. The button tag is not allowed inside input groups
C. The input must come after the button
D. The placeholder attribute is invalid inside input groups

Solution

  1. Step 1: Check Bootstrap input group button usage

    Bootstrap 5 removed input-group-btn. Buttons inside input groups should be direct children with class btn.
  2. Step 2: Verify other options

    Buttons are allowed inside input groups, input can be before or after button, and placeholder is valid on inputs.
  3. Final Answer:

    The class 'input-group-btn' is deprecated and should be replaced -> Option A
  4. Quick Check:

    input-group-btn deprecated in Bootstrap 5 = D [OK]
Hint: Use btn class directly; input-group-btn is outdated [OK]
Common Mistakes:
  • Keeping input-group-btn class from older Bootstrap versions
  • Thinking buttons can't be inside input groups
  • Believing placeholder is invalid in input groups
5. You want to create an input group with a dropdown button on the right side of a text input. Which Bootstrap structure is correct?
hard
A.
Options
B.
Options
C.
Options
D.
Options

Solution

  1. Step 1: Understand input group with dropdown button

    The dropdown button must be a button with dropdown-toggle class and proper data-bs-toggle attribute inside the input group after the input.
  2. Step 2: Check structure correctness

    Options correctly places the input first, then the dropdown button with toggle attributes, followed by the dropdown menu list.
  3. Final Answer:

    This structure correctly creates an input group with a dropdown button on the right -> Option D
  4. Quick Check:

    Dropdown button after input with toggle attribute = A [OK]
Hint: Dropdown button needs toggle attribute and follows input inside input-group [OK]
Common Mistakes:
  • Placing dropdown menu before button
  • Using span instead of button for dropdown toggle
  • Putting button before input in input group
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard