LESSON 01 / 03

Forms & Inputs

Forms let people type, choose and send. Learn inputs, labels, buttons, dropdowns, checkboxes and radio buttons.

๐ŸŽ“Beginnerlevel
โฑ๏ธ35 minto finish
โœ๏ธ2activities

๐Ÿ“‚ Forms & Semantic HTML๐Ÿท๏ธ HTML

๐ŸŽฏ By the end of this lesson you canโ€ฆ

  • Build a form with labelled inputs
  • Choose the right input type
  • Use select, checkbox, radio and textarea
๐ŸŒ HTML ยท CSS ยท JS form.html ๐Ÿ‘† Tap a line to explain it
1<style>2  form { display: grid; gap: 10px; max-width: 320px; font-family: system-ui; }3  label { display: grid; gap: 4px; font-weight: 600; }4  input, select, textarea { padding: 8px; border-radius: 8px; border: 2px solid #ccc; font: inherit; }5</style>6<form>7  <label>Full name <input type="text" name="name"></label>8  <label>Email <input type="email" name="email"></label>9  <label>Age <input type="number" name="age" min="5" max="100"></label>10  <label>Class11    <select name="class">12      <option>Class 6</option>13      <option>Class 7</option>14      <option>Class 8</option>15    </select>16  </label>17  <fieldset>18    <legend>Favourite subject</legend>19    <label><input type="radio" name="subject" value="maths"> Maths</label>20    <label><input type="radio" name="subject" value="art"> Art</label>21  </fieldset>22  <label><input type="checkbox" name="news"> Send me updates</label>23  <label>Message <textarea name="msg" rows="3"></textarea></label>24  <button>Send</button>25</form>
Useful input types
typeGood for
textnames, short answers
email / tel / urlcontact details (right keyboard on phones)
number / rangeamounts, sliders
date / timecalendars built in
passwordhidden typing
checkbox / radiomany choices / one choice
fileuploads
๐Ÿ’ก Concept check
You want users to pick exactly ONE size: S, M or L. Which input?
๐Ÿ› ๏ธ Feedback form

Build a form with a labelled text input for the name, a labelled email input, a dropdown with the options Good / Okay / Bad, and a Submit button.

๐Ÿ“Œ Key takeaways

  • Every input needs a <label> โ€” click the label and the input gets focus.
  • The type changes the keyboard and behaviour: email, number, date, passwordโ€ฆ
  • Radio buttons with the same name let you pick one; checkboxes let you pick many.

Finished reading & practising?

Saved in this browser. Create a free account to keep it forever.