diffsnack
HTML Guess the result Level 5

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>
  1. Yes, it is the first choice
  2. Yes, and it picks both guitar options
  3. No, it is only a group heading
  4. No, it is hidden from visitors

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.

Play this exercise Learn the concept: Form fields and labels