0
0
HTMLmarkup~20 mins

Select dropdown in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Select Dropdown Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What is the visible output of this select dropdown?
Look at the HTML code below. What will the user see in the dropdown menu when they click it?
HTML
<label for="fruits">Choose a fruit:</label>
<select id="fruits" name="fruits">
  <option value="apple">Apple</option>
  <option value="banana" selected>Banana</option>
  <option value="cherry">Cherry</option>
</select>
AA dropdown with only Banana option visible.
BA dropdown with options Apple, Banana, Cherry; Banana is selected by default.
CA dropdown with options Apple, Banana, Cherry; Cherry is selected by default.
DA dropdown with options Apple, Banana, Cherry; Apple is selected by default.
Attempts:
2 left
💡 Hint
Look for the 'selected' attribute inside the option tags.
📝 Syntax
intermediate
2:00remaining
Which option causes a syntax error in this select dropdown?
Identify which select dropdown code snippet will cause a syntax error in HTML.
A<select><option value="1">One</option><option value="2">Two</option></select>
B>tceles/<>noitpo/<owT>"2"=eulav noitpo<>noitpo/<enO>"1"=eulav noitpo<>tceles<
C<select><option value="1">One<option value="2">Two</option></select>
Dselect><option value="1">One</option><option value="2">Two</option></select>
Attempts:
2 left
💡 Hint
Check if all option tags are properly closed.
accessibility
advanced
2:00remaining
Which select dropdown is most accessible for screen readers?
Choose the select dropdown code that best supports screen reader users.
A<select><option>Red</option><option>Green</option><option>Blue</option></select>
B>tceles/<>noitpo/<eulB>noitpo<>noitpo/<neerG>noitpo<>noitpo/<deR>noitpo<>tceles<
C<select aria-label="Pick a color"><option>Red</option><option>Green</option><option>Blue</option></select>
D<label for="colors">Pick a color:</label><select id="colors"><option>Red</option><option>Green</option><option>Blue</option></select>
Attempts:
2 left
💡 Hint
Labels help screen readers understand form controls.
layout
advanced
2:00remaining
How to make a select dropdown fill the full width of its container?
Given a select dropdown inside a container, which CSS rule makes the dropdown stretch to fill the container's width?
HTML
<div class="container">
  <select>
    <option>Option 1</option>
    <option>Option 2</option>
  </select>
</div>
Aselect { width: 100%; }
Bselect { display: inline; }
Cselect { max-width: 50%; }
Dselect { float: left; }
Attempts:
2 left
💡 Hint
Think about how to make an element take all available horizontal space.
🧠 Conceptual
expert
2:00remaining
What is the value of the select element after this user interaction?
Consider this HTML and JavaScript. The user selects the third option. What is the value of the select element after the change?
HTML
<select id="mySelect">
  <option value="a">Alpha</option>
  <option value="b">Beta</option>
  <option value="c">Gamma</option>
</select>

<script>
  const select = document.getElementById('mySelect');
  select.value = 'b';
  select.value = 'c';
</script>
A"c"
B"b"
C"a"
Dundefined
Attempts:
2 left
💡 Hint
The last assignment to select.value sets the final value.