Skip to content
FORGENO ADS GAMESUnlock all $8

HTML · Unit 3: Tables, forms and a profile card · Lesson 4 of 5

Buttons and choices

<button> makes a button.

Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.

The idea

<button> makes a button. Inside a form, type="submit" sends the form. type="button" does nothing on its own until JavaScript gives it a job.

<select> makes a drop-down. Each choice is an <option>: its value is what gets sent and its text is what people see.

<textarea> is a box for longer text. Unlike <input>, it has a closing tag.

Worked example

HTML

<label for="size">Size</label>
<select id="size" name="size">
  <option value="s">Small</option>
  <option value="m">Medium</option>
</select>
<label for="note">Note</label>
<textarea id="note" name="note"></textarea>
<button type="submit">Order</button>

Key terms

Button
A <button>. type="submit" sends its form; type="button" waits for JavaScript.
Select
A drop-down made of <option> elements.

Practise it in Code Academy

It has 4 exercises (multiple choice, fill in the blank, fix the broken code and write code from a prompt) and takes about 6 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.

Every lesson is free: no ads, no lives and no paywall.