What is the main difference between radio buttons and checkboxes in HTML?
Radio buttons allow the user to select only one option from a group, while checkboxes let the user select multiple options independently.
Click to reveal answer
beginner
How do you group radio buttons so only one can be selected at a time?
Give all radio buttons in the group the same name attribute value. This links them so only one can be selected.
Click to reveal answer
beginner
What attribute do you use to make a checkbox or radio button selected by default?
Use the checked attribute on the <input> element to make it selected when the page loads.
Click to reveal answer
beginner
Why should you use <label> elements with radio buttons and checkboxes?
Labels improve accessibility by making it easier to click the input and help screen readers understand the form controls.
Click to reveal answer
intermediate
How can you make a group of checkboxes or radio buttons accessible for keyboard users?
Use <label> tags linked with inputs, ensure logical tab order, and use <fieldset> with <legend> to group related controls.
Click to reveal answer
Which attribute groups radio buttons so only one can be selected?
Aname
Bid
Cvalue
Dchecked
✗ Incorrect
Radio buttons with the same 'name' attribute belong to the same group, allowing only one selection.
What happens if you give checkboxes the same name attribute?
ACheckboxes behave like radio buttons
BOnly one checkbox can be selected
CCheckboxes become disabled
DMultiple checkboxes can be selected independently
✗ Incorrect
Checkboxes with the same name can still be selected independently; the name attribute does not limit selection for checkboxes.
Which HTML element improves accessibility by linking text to a checkbox or radio button?
A<div>
B<span>
C<label>
D<section>
✗ Incorrect
The
How do you make a radio button selected by default?
AAdd the attribute active
BAdd the attribute checked
CAdd the attribute default
DAdd the attribute selected
✗ Incorrect
The 'checked' attribute marks a radio button or checkbox as selected when the page loads.
Which input type allows multiple selections?
Acheckbox
Bradio
Ctext
Dbutton
✗ Incorrect
Checkboxes allow users to select multiple options independently.
Explain how to create a group of radio buttons where only one option can be selected. Include how to make one option selected by default.
Think about how browsers know which radio buttons belong together.
You got /4 concepts.
Describe the accessibility best practices when using checkboxes and radio buttons in a form.
Consider how people using keyboards or screen readers interact with forms.
You got /4 concepts.
Practice
(1/5)
1. Which input type allows a user to select only one option from a group? <input type="?">
easy
A. button
B. checkbox
C. radio
D. text
Solution
Step 1: Understand input types
The radio input type is designed for selecting one option from many.
Step 2: Compare with other types
checkbox allows multiple selections, text is for typing, and button triggers actions.
Final Answer:
radio -> Option C
Quick Check:
Single choice = radio [OK]
Hint: Radio = one choice, Checkbox = many choices [OK]
Common Mistakes:
Confusing checkbox with radio
Thinking text input allows selection
Using button for selection
2. Which of the following is the correct syntax to create a checkbox with label "Subscribe"?
easy
A. Subscribe
B. Subscribe
C. Subscribe
D. Subscribe
Solution
Step 1: Check input and label usage
The correct checkbox uses <input type="checkbox"> and a <label> with matching for attribute.
Step 2: Identify invalid syntax
The other options use invalid syntax: A uses a non-existent <checkbox> tag, B incorrectly closes the input with text inside, and D uses an invalid checkbox attribute.
Final Answer:
<input type="checkbox" id="sub"><label for="sub">Subscribe</label> -> Option B
Quick Check:
Checkbox + label with for = correct syntax [OK]
Hint: Use with [OK]
Common Mistakes:
Using non-existent <checkbox> tag
Missing type attribute
Not linking label with for attribute
3. What will be the result when this HTML is rendered?
A. The second label is missing the for attribute linking it to the checkbox
B. The first checkbox is missing a name attribute
C. Checkboxes cannot have labels
D. The id attribute should be on the label, not the input
Solution
Step 1: Check label associations
The first label uses for="news" linking it to the checkbox with id "news".
Step 2: Identify missing for attribute
The second label lacks a for attribute, so it is not linked to the checkbox with id "updates".
Final Answer:
The second label is missing the for attribute linking it to the checkbox -> Option A
Quick Check:
Label needs for attribute to link input [OK]
Hint: Labels must have for attribute matching input id [OK]
Common Mistakes:
Assuming name attribute is required for labels
Thinking labels can't be used with checkboxes
Placing id on label instead of input
5. You want to create a form where users can select their favorite fruits. They can pick any number of fruits, but only one fruit size (Small, Medium, Large). Which input types should you use for fruits and sizes respectively?
hard
A. Radio buttons for both fruits and sizes
B. Radio buttons for fruits, Checkboxes for sizes
C. Checkboxes for both fruits and sizes
D. Checkboxes for fruits, Radio buttons for sizes
Solution
Step 1: Understand selection rules
Users can pick multiple fruits, so checkboxes are suitable for fruits.
Step 2: Single choice for size
Only one size can be selected, so radio buttons are suitable for sizes.
Final Answer:
Checkboxes for fruits, Radio buttons for sizes -> Option D
Quick Check:
Multiple choice = checkbox, single choice = radio [OK]
Hint: Multiple selections use checkbox; single selection uses radio [OK]
Common Mistakes:
Using radio buttons for multiple selections
Using checkboxes for single selection
Not grouping radio buttons by name
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.