Skip to content
techsnow

HTML Forms

Select and Textarea

<label for="course">Choose a course</label>
<select id="course" name="course">
  <option value="">-- Select --</option>
  <option value="python">Python</option>
  <option value="js" selected>JavaScript</option>
  <optgroup label="Web">
    <option value="html">HTML</option>
    <option value="css">CSS</option>
  </optgroup>
</select>
  • <option> is one choice. Its value is what gets sent.
  • selected picks the default option.
  • <optgroup> groups options under a heading.
  • Add multiple to <select> to allow several choices.

Multi-line text

<label for="msg">Your message</label>
<textarea id="msg" name="message" rows="5" maxlength="500" placeholder="Write here..."></textarea>

Suggestions with datalist

<input list="cities" name="city">
<datalist id="cities">
  <option value="Lahore">
  <option value="Karachi">
  <option value="Islamabad">
</datalist>

A <datalist> suggests values but still lets the user type anything.