A form control in Bootstrap is a styled HTML input element like text boxes, checkboxes, or selects that lets users enter or choose data easily and consistently.
Click to reveal answer
beginner
How do you make a text input field using Bootstrap?
Use the <input> element with the class form-control. For example: <input type="text" class="form-control">.
Click to reveal answer
beginner
Why should you use form-label with inputs?
The <code>form-label</code> class styles labels nicely and connects them to inputs for better accessibility and user experience.
Click to reveal answer
beginner
What Bootstrap class do you use for a select dropdown?
Use the <code>form-select</code> class on the <code><select></code> element to get a styled dropdown.
Click to reveal answer
beginner
How can you make a form control disabled in Bootstrap?
Add the disabled attribute to the input element. Bootstrap styles it to look inactive and prevents user interaction.
Click to reveal answer
Which class do you add to an <input> to style it as a Bootstrap form control?
Aform-input
Binput-style
Ccontrol-input
Dform-control
✗ Incorrect
The correct Bootstrap class for styling inputs is form-control.
What element and class combination creates a styled dropdown in Bootstrap?
A. A styled email input box with placeholder text and accessible label
B. A plain input box without any styling or placeholder
C. A button labeled 'Enter email'
D. An error because aria-label is invalid here
Solution
Step 1: Analyze the input element
The input is of type email, has the Bootstrap class form-control, a placeholder, and an ARIA label.
Step 2: Understand the visual and accessibility effects
The form-control class styles the input nicely. The placeholder shows faint text inside the box. The aria-label helps screen readers identify the input as 'Email address'.
Final Answer:
A styled email input box with placeholder text and accessible label -> Option A
5. You want to create a dropdown menu for selecting a country using Bootstrap. Which code snippet correctly applies Bootstrap form control classes and accessibility best practices?
hard
A. <select class="form-select" aria-label="Country selector"><option>USA</option><option>Canada</option></select>
B. <select class="form-control" aria-labelledby="country"><option>USA</option><option>Canada</option></select>
C. <select class="form-select" aria-label="Country selector"><option selected>Select country</option><option>USA</option><option>Canada</option></select>
D. <select class="form-control" aria-label="country"><option>USA</option><option>Canada</option></select>
Solution
Step 1: Identify correct Bootstrap class for dropdowns
Bootstrap uses form-select for styling select dropdowns, not form-control.
Step 2: Check accessibility and usability
Using aria-label="Country selector" provides an accessible name. Including a default option like Select country with selected guides users.
Step 3: Compare options
<select class="form-select" aria-label="Country selector"><option selected>Select country</option><option>USA</option><option>Canada</option></select> uses form-select, has an accessible label, and a default selected option, making it best practice.
Final Answer:
<select class="form-select" aria-label="Country selector"><option selected>Select country</option><option>USA</option><option>Canada</option></select> -> Option C