Form Summary

In this lesson, we learned how to build forms and found out that:

  • A form is created with the form element and its attributes:
    • action: the URL the data is sent to,
    • method: how the data is sent: GET in the address (for example for a search) or POST inside the request (for example for logging in).
  • Inputs are created with the input element and its attributes:
    • type: the type of the input, for example text, password, email, number, date, range, radio or checkbox,
    • name: the name that is sent together with the input's value, for example name=Tim,
    • id: a unique identifier, which connects the input to its label,
    • value: a pre-filled value, or for a radio button, the value sent when it's chosen.
  • Radio buttons with the same name form a group in which only one can be chosen. Checkboxes are independent of each other.
  • A drop-down list is created with the select element with option elements inside it, and a box for longer text with the textarea element.
  • Every input needs a label: the label element, whose for attribute has the same value as the id of its input. Clicking the label puts the cursor into the input, and screen readers read it aloud.
  • A form is sent with the button <button type="submit">Submit</button> (or <input type="submit" value="Submit">).
  • An input is made required with the required attribute.

In the next lesson, a final project awaits you, in which you'll use what you've learned in the whole course.

Instructions

Congratulations on completing the fifth lesson! The editor contains your final code from this lesson. Now you can customize the form with your newly acquired knowledge, and then move on to the final project.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

11/11