HTML forms are used to collect user input and send it to a server for processing.
Forms are a core part of websites such as login pages, registration forms, contact forms, search boxes, and feedback systems.
The <form> Tag
All form elements are placed inside the <form> tag. The form tag defines how data is sent and where it is sent.
In this example:
- <form> defines the form container
- <input> is used to collect user input
- The submit button sends the form data
The action Attribute
The action attribute specifies the URL where the form data is sent when the user submits the form.
If the action attribute is not specified, the form submits data to the same page.
The method Attribute
The method attribute defines how form data is sent.
Common methods are GET and POST.
GET sends data through the URL and is used for searches.
POST sends data securely in the request body and is used for sensitive data.
Common Uses of HTML Forms
- Login and registration
- Contact forms
- Search functionality
- Data submission to servers
Why Forms Matter for Jobs
Forms connect frontend and backend systems.
Understanding forms is essential for frontend developers, backend developers, and full-stack developers.
Practice Task
Create a simple contact form with name input and submit button. Add action and method attributes.
What You Will Learn Next
In the next lesson, you will learn about different HTML input types used in forms.