0
0
HTMLmarkup~20 mins

Radio buttons and checkboxes in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Radio and Checkbox Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding radio button grouping
What happens when multiple radio buttons share the same name attribute in an HTML form?
AOnly one radio button in the group can be selected at a time.
BAll radio buttons can be selected independently.
CThe radio buttons become disabled automatically.
DThe radio buttons behave like checkboxes and allow multiple selections.
Attempts:
2 left
💡 Hint
Think about how radio buttons are designed to let users pick one option from many.
📝 Syntax
intermediate
1:30remaining
Correct checkbox syntax
Which option shows the correct HTML syntax for a checkbox input with label 'Subscribe'?
A<input type="checkbox" id="subscribe"> <label for="subscribe">Subscribe</label>
B<checkbox id="subscribe">Subscribe</checkbox>
C<input type="check" id="subscribe"> <label>Subscribe</label>
D<input type="checkbox" name="subscribe">Subscribe</input>
Attempts:
2 left
💡 Hint
Remember the correct input type and how labels link to inputs.
rendering
advanced
2:00remaining
Visual result of grouped radio buttons
What will the user see when this HTML code is rendered in a browser?
<form>
  <input type="radio" name="color" id="red" value="red">
  <label for="red">Red</label>
  <input type="radio" name="color" id="blue" value="blue">
  <label for="blue">Blue</label>
</form>
ATwo buttons labeled 'Red' and 'Blue' that submit the form when clicked.
BTwo checkboxes labeled 'Red' and 'Blue' that can be selected independently.
CTwo radio buttons labeled 'Red' and 'Blue' where only one can be selected at a time.
DTwo text input fields labeled 'Red' and 'Blue' for typing.
Attempts:
2 left
💡 Hint
Look at the input types and the shared name attribute.
accessibility
advanced
2:00remaining
Improving checkbox accessibility
Which option best improves accessibility for a checkbox input labeled 'Accept Terms'?
A<input type="checkbox" id="terms"><label>Accept Terms</label>
B<input type="checkbox" aria-labelledby="terms-label"><span id="terms-label">Accept Terms</span>
C<input type="checkbox" id="terms" aria-label="Accept Terms">
D<input type="checkbox" id="terms"><label for="terms">Accept Terms</label>
Attempts:
2 left
💡 Hint
Consider how screen readers associate labels with inputs.
selector
expert
2:00remaining
CSS selector for checked checkboxes
Which CSS selector correctly styles only the checkboxes that are checked?
Ainput[type="checkbox"]:check { background-color: lightgreen; }
Binput[type="checkbox"]:checked { background-color: lightgreen; }
Cinput:checked[type="checkbox"] { background-color: lightgreen; }
Dinput[type="checkbox" checked] { background-color: lightgreen; }
Attempts:
2 left
💡 Hint
Look for the correct pseudo-class syntax for checked inputs.