skip to Main Content

Free Code Camp Learn HTML says this code is incorrect even though it is exactly what the instructions said to do.

```<label>How did you hear about us?
  <select>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
  </select>
</label>```

I must be missing something really simple.

2

Answers


  1. Yes, you can put <select> element in <label>. The error may be caused by the empty <option> tags. Try putting values in the <option> elements. You can also try to put "for" attribute in the label tag. The value of the for attribute must match the id of the select element.

    <label for="source">
      How did you hear about us?
      <select id="source">
        <option>Facebook</option>
        <option>Google</option>
      </select>
    </label>
    
    Login or Signup to reply.
  2. @here, refer this link [https://codepen.io/dosullz/pen/QNxdzd][1]
    still make sense if you give options
    [1]: https://codepen.io/dosullz/pen/QNxdzd

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search