The last <option> for Blue is missing its closing </option> tag, which is required for valid HTML.
Step 2: Verify other parts
The name attribute is valid on <select>, options can have value attributes, and multiple options are allowed.
Final Answer:
Missing closing tag for the last <option> -> Option C
Quick Check:
All <option> tags must be closed [OK]
Hint: Always close each <option> tag properly [OK]
Common Mistakes:
Forgetting to close <option> tags
Thinking name attribute is invalid on <select>
Believing options can't have values
5. You want to create a dropdown for selecting a country with these requirements: - The dropdown must have a label for accessibility. - The default visible option should say 'Select a country' and not be selectable. - Options: USA, Canada, Mexico. Which code snippet meets all these requirements?
hard
A. <select name="country">
<option>Select a country</option>
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select>
B. <label for="country">Country:</label>
<select id="country" name="country">
<option value="" disabled selected>Select a country</option>
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select>
C. <label>Country</label>
<select id="country">
<option value="" selected>Select a country</option>
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select>
D. <label for="country">Country:</label>
<select id="country" name="country">
<option value="">Select a country</option>
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select>
Solution
Step 1: Check for label linked to select
<label for="country">Country:</label>
<select id="country" name="country">
<option value="" disabled selected>Select a country</option>
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select> uses <label for="country"> and <select id="country">, linking label and dropdown for accessibility.
Step 2: Verify default option is disabled and selected
The first option in A has disabled selected attributes, so it shows as default but cannot be chosen.
Step 3: Confirm options list
Options USA, Canada, Mexico are correctly listed with values.
Final Answer:
This code snippet meets all requirements -> Option B