Skip to content
UNWIND Code Lab Co-funded by the European Union
Forms 1: Labels and Input Types
Log In

Forms 1: Labels and Input Types

  • 6 min reading
  • 6 min activity
0 of 4 tasks doneup to 85 XP
  1. Sent to the server?15 XPTo do
  2. The right type for the job15 XPTo do
  3. Sign-up form30 XPTo do
  4. Picker party25 XPOptional

So far your page talks. With a form it listens: visitors type, choose and send. The course slides say forms make the internet different from a newspaper or TV.

In this lesson
  • Build a form that sends data, and know what action and method do.
  • Connect each label to its field.
  • Choose input types, and use name, placeholder, required, min/max and minlength.
Remember

In Unit 1 you gave elements an id: a name for one element on the page. Forms use it a lot, together with name.

Quick check: how many elements can have the same id?

Only one. An id is used once per page.

A form sends data

<form action="/signup" method="post">
  ... the fields ...
  <button type="submit">Sign up</button>
</form>

The fields go between <form> and </form>. The button sends the data to a program on a server: action is its address, method the way.

method="get"

The data goes into the address: /search?q=bread. Good for searches.

method="post"

The data goes inside the request. Good for sign-up and contact forms.

POST is not secret

The slides say POST is hidden and secure. More exactly: POST keeps data out of the address bar, but it is not encrypted. Only HTTPS (the lock next to the address) keeps data private on the way.

Every field needs a label

<label for="email">Email</label>
<input type="email" id="email" name="email">
Email for="email" id="email" Same word: the label belongs to the field.
The for of the label is the id of the field.

Now tapping "Email" puts the cursor in the field, and screen readers say "Email" when people reach the field. A placeholder is only a light hint: it disappears when people type, so it never replaces the label.

The attributes of a field

AttributeWhat it does
nameThe key sent with the value: email=ayla@example.com. No name, nothing sent.
idConnects the label; CSS and JavaScript use it. The slides say "id or name" is sent: only name is.
valueThe start value of a field.
placeholderA light hint in the empty field.
requiredThe form is not sent while this field is empty.
disabledNobody can type in it, and it is not sent.
minlength, maxlengthThe smallest and biggest number of characters.
Grouping

Sent to the server?

Required 15 XP

Input types

The type changes the field, and on a phone also the keyboard.

TypeWhat it does
textOne line of text.
emailChecks the @. pattern can ask for a stricter format.
passwordHides the characters on screen, but does not encrypt them.
numberNumbers, with min, max and step.
telNumber pad; any text, because phone numbers differ by country.
dateA calendar. Values are YYYY-MM-DD: min="2026-11-01".
time, monthHours and minutes; month and year (some computer browsers show a text box).
color, rangeA colour picker; a slider from min to max. Write the scale in the label.
Slide bug: spaces in the type

Some slide headings write type=" password ". With spaces the browser does not know the type and shows a normal text box: the password is visible. Write type="password".

More details from the slides

A date field reduces mistakes, but people can still type a date. min and max are fixed dates; limits that move with today's date need JavaScript. In a time field, step counts seconds: step="900" is 15 minutes. A colour picker sends a code like #0285C3.

Matching

The right type for the job

Required 15 XP

Your sign-up form

Fix the form one check at a time. Browser checks help visitors, but the server must check the data again.

Practice

Sign-up form

Required 30 XP

This sign-up form has no labels, and one type has a bug from the slides. Give every field a label, make the email field an email field, fix the password, and add a number field. The CSS tab puts each label on its own line.

Bonus: Picker party

Optional: a time, a colour and a slider, for extra XP and a Mission 2 star.

Practice

Picker party

25 XP

Optional extra practice. Plan a study evening: add a start time, a colour for your notes and a slider for your energy. Every new field needs a label.

Key words

Form
A part of a page where visitors type or choose, and then send.
Field
One place to type or choose, like <input>.
Label
The visible name of a field, connected with for and id.
name
The key that is sent to the server with the value.

In short

  • A form sends its fields to action, with get or post.
  • Every field gets a label: for = id.
  • Only fields with a name are sent; the placeholder is only a hint.
  • The type sets the field and the phone keyboard. No spaces inside the quotes.
Next time

Checkboxes, radio buttons, drop-down lists and a text area for long messages.

Sources

  1. MDN Web Docs (2026). Your first form.
  2. MDN Web Docs (2026). Sending form data (GET, POST, HTTPS, server checks).
  3. MDN Web Docs (2026). <input>: The HTML Input element (name, disabled, unknown types).
  4. MDN Web Docs (2026). <input type="password">.
  5. MDN Web Docs (2026). <input type="month"> (browser support).
  6. W3C WAI (2024). Labeling Controls.

End of the lesson

This lesson: 0 of 95 XP

Code Cards in this lesson: 9

  • <form>
  • <label>
  • <input>
  • type="email"
  • type="password"
  • type="number"
  • type="date"
  • required
  • pattern