HTML exercise: Form fields and labels — Can a visitor pick "Guitar" itself from this menu?
The exercise
Can a visitor pick "Guitar" itself from this menu?
1<label for="course">Course</label>
2<select id="course" name="course">
3 <optgroup label="Guitar">
4 <option value="ac">Acoustic</option>
5 <option value="el">Electric</option>
6 </optgroup>
7 <optgroup label="Theory">
8 <option value="ch">Chords</option>
9 </optgroup>
10</select>
Solution
Answer: No, it is only a group heading
An <optgroup> groups related <option> items under a heading set by its label attribute. Visitors can see "Guitar" as a group title, but they can only pick an <option> inside it.