Form Summary
In this lesson, we learned how to build forms and found out that:
- A form is created with the
formelement and its attributes:action: the URL the data is sent to,method: how the data is sent:GETin the address (for example for a search) orPOSTinside the request (for example for logging in).
- Inputs are created with the
inputelement and its attributes:type: the type of the input, for exampletext,password,email,number,date,range,radioorcheckbox,name: the name that is sent together with the input's value, for examplename=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
nameform a group in which only one can be chosen. Checkboxes are independent of each other. - A drop-down list is created with the
selectelement withoptionelements inside it, and a box for longer text with thetextareaelement. - Every input needs a label: the
labelelement, whoseforattribute has the same value as theidof 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
requiredattribute.
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
11/11