Home / Learn HTML / HTML Form Elements

HTML Form Elements

Besides input there are other form elements: select, textarea, button, datalist, output, progress, meter.

Definition

Besides input a form uses other elements: label names a control, select with option and optgroup makes a drop down, textarea a multi line box, button a button, datalist a list of suggestions, fieldset with legend groups controls, output shows a result and progress and meter show bars.

Tip:The best way to connect a label is <label for="x"> and <input id="x">. Clicking the label then focuses the input.

Theory in plain words

A well built formlegendlabel + inputfieldsetlabel + textareabuttonform
A well built form

What it is

Form elements include select, textarea, label, fieldset, datalist, progress and meter, in addition to input and button.

Why we use it

Different data needs different controls: a list of options, a long message, a group of radio buttons.

How it works

Each control sends its name and value on submit. label and fieldset connect and group them for accessibility.

Where it is used

  • Country dropdown with select
  • Message box with textarea
  • Radio groups inside fieldset
Drop down list (select)Try it Yourself
Option values and selectedTry it Yourself
Option groupsTry it Yourself
Visible list and multiple choiceTry it Yourself

Hold Ctrl (or Cmd) to pick more than one.

Text areaTry it Yourself
Text area without resizeTry it Yourself
ButtonsTry it Yourself
Button with an iconTry it Yourself
Datalist (suggestions)Try it Yourself
OutputTry it Yourself
Progress barTry it Yourself
MeterTry it Yourself

Meter shows a measured value, progress shows how far a task has gone.

Label with checkboxTry it Yourself
Fieldset disabledTry it Yourself
Select styledTry it Yourself
Dependent action with JavaScriptTry it Yourself

Quick quiz

1. Which tag makes a drop down?

2. Which holds many lines of text?

3. Which tag shows task progress?

Common questions

Which tag makes a drop down?

<select>. select with option.

Which holds many lines of text?

<textarea>. textarea is multi line.

Which tag shows task progress?

<progress>. meter is for measurements.

My notes
Ask a question about this lesson