HTML Form Elements

Forms are built from more than text boxes: dropdowns, text areas, labels, and buttons.

Each kind of input has its own element or type. Choosing the right one gives users a control that fits the data you are asking for.

Common Form Elements

ElementPurpose
<input>A single-line field
<textarea>Multi-line text
<select>A dropdown menu
<label>A caption for a field
<button>A clickable button

A Dropdown

select and option

<!DOCTYPE html>
<html>
<body>

<select name="role">
  <option value="dev">Developer</option>
  <option value="design">Designer</option>
</select>

</body>
</html>

A Text Area

Multi-line input

<!DOCTYPE html>
<html>
<body>

<label>Message:</label>
<textarea name="message" rows="4"></textarea>

</body>
</html>
Note: Each <option> has a value that is submitted and a label between the tags that the user sees.

Exercise: HTML Form Elements

Which combination lets a user pick exactly one value from a fixed, closed list of choices?