21. Introducing Forms and the <form> Tag
Forms are how we collect user input (login details, search queries, feedback).
21.1 The <form> Container
All input elements must be placed inside the <form> tag. This tag handles how and where the data is sent.
21.2 Key Form Attributes
action: Specifies the URL where the form data will be submitted (usually a server-side script).method: Specifies the HTTP method used to send the data. The two most common areGETandPOST.
| Method | Use Case | Description |
|---|---|---|
GET | Retrieving data (e.g., searching). | Appends form data to the URL. Visible and limited in length. |
POST | Submitting data (e.g., logins, file uploads). | Sends data in the body of the request. Secure and supports large amounts of data. |
html