Aral Code

Forms Lesson 32 of 42

HTML Form Elements — select, textarea, button and datalist

Learn the other form elements — dropdowns with select and option, multi-line text with textarea, buttons, datalist suggestions, and output.

Inputs aren't the only form fields. For dropdown menus, long answers, and different kinds of buttons, HTML has a few more elements. This lesson covers them and ends with a complete, realistic form.

select — dropdown lists

A <select> shows a dropdown. Each choice is an <option>. The value is what gets sent; the text between the tags is what the user sees.

Example Choosing a region
<label for="region">Region:</label>
<select id="region" name="region">
  <option value="">-- Choose your region --</option>
  <option value="ncr">NCR – Metro Manila</option>
  <option value="r3">Region III – Central Luzon</option>
  <option value="r4a">Region IV-A – CALABARZON</option>
  <option value="r7">Region VII – Central Visayas</option>
  <option value="r11">Region XI – Davao Region</option>
</select>

Useful options

  • selected on an option makes it the default choice.
  • <optgroup label="..."> groups options under a heading.
  • multiple on the select allows picking several options (with Ctrl or Cmd), but checkboxes are usually easier for users.
Example Grouped options
<label for="strand">SHS Strand:</label>
<select id="strand" name="strand">
  <optgroup label="Academic Track">
    <option value="stem">STEM</option>
    <option value="abm">ABM</option>
    <option value="humss" selected>HUMSS</option>
    <option value="gas">GAS</option>
  </optgroup>
  <optgroup label="TVL Track">
    <option value="ict">ICT</option>
    <option value="he">Home Economics</option>
    <option value="ia">Industrial Arts</option>
  </optgroup>
</select>

textarea — long answers

<input type="text"> is only one line. For comments, messages, and essay answers, use <textarea>. Unlike input, it has a closing tag, and any default text goes between the tags.

Example A message box
<label for="msg">Your message to the class adviser:</label><br>
<textarea id="msg" name="message" rows="5" cols="40" placeholder="Write your concern here..."></textarea>
  • rows and cols set the starting size (in lines and characters). CSS width works too.
  • maxlength="500" limits how many characters can be typed.
  • Most browsers let users drag the corner to resize it.

button — three types

The <button> element can contain text, icons or images. Its type matters a lot:

TypeWhat it does
type="submit"Sends the form (the default inside a form)
type="reset"Clears all fields back to their starting values
type="button"Does nothing by itself — used with JavaScript
Example Button types
<form>
  <input type="text" name="nickname" value="Change me">
  <button type="submit">✅ Submit</button>
  <button type="reset">↺ Reset</button>
  <button type="button" onclick="alert('Hello from JavaScript!')">👋 Say hi</button>
</form>

datalist — suggestions while typing

<datalist> gives an input a list of suggestions, but the user can still type anything. Connect them with the input's list attribute and the datalist's id.

Example Suggested cities
<label for="city">City:</label>
<input id="city" name="city" list="cities">
<datalist id="cities">
  <option value="Manila">
  <option value="Quezon City">
  <option value="Cebu City">
  <option value="Davao City">
  <option value="Iloilo City">
  <option value="Baguio City">
</datalist>

Putting it all together

Here's a full enrollment-style form using everything from the three form lessons. Read it slowly — every line uses something you've learned.

Example School club registration form
<style>
  form { font-family: Arial, sans-serif; max-width: 420px; }
  label { display: block; margin-top: 12px; font-weight: bold; }
  input, select, textarea { width: 100%; padding: 8px; font-size: 16px; box-sizing: border-box; }
  fieldset { margin-top: 14px; border-radius: 8px; }
  fieldset label { display: inline; font-weight: normal; }
  fieldset input { width: auto; }
  button { margin-top: 16px; padding: 10px 18px; font-size: 16px; background: #0f5c4d; color: white; border: 0; border-radius: 8px; }
</style>
<form action="/register" method="post">
  <h2>Club Registration</h2>

  <label for="name">Full name</label>
  <input id="name" name="name" autocomplete="name" required>

  <label for="email">Email</label>
  <input type="email" id="email" name="email" autocomplete="email">

  <label for="club">Club</label>
  <select id="club" name="club" required>
    <option value="">-- Choose a club --</option>
    <option>Coding Club</option>
    <option>Robotics Club</option>
    <option>Journalism Club</option>
  </select>

  <fieldset>
    <legend>Grade level</legend>
    <label><input type="radio" name="grade" value="7" required> 7</label>
    <label><input type="radio" name="grade" value="8"> 8</label>
    <label><input type="radio" name="grade" value="9"> 9</label>
    <label><input type="radio" name="grade" value="10"> 10</label>
  </fieldset>

  <label for="why">Why do you want to join?</label>
  <textarea id="why" name="why" rows="4" maxlength="300"></textarea>

  <button type="submit">Register</button>
</form>

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Which element creates a dropdown list?
2. Which element is best for a long comment or essay answer?
3. What does a <button> inside a form do by default?
4. How is a <datalist> connected to an input?

By Sir Reyel · Last updated 2026-12-04