The <form>
tag in HTML is used to collect user input. It’s the foundation of almost every interactive website, including login pages, contact forms, search bars, and surveys.
Simply put, a form allows users to enter data, such as their name, email, or password, and send it to the server for processing.
Basic Syntax:

-
action
defines where the form data will be sent (usually a URL or file). -
method
defines how the data will be sent:-
GET
for appending data to the URL -
POST
for sending data securely in the request body
-
Common Form Elements
Here are some commonly used input elements in a form:
-
Text Input

-
Email Input

-
Password Input

-
Radio Buttons

-
Checkboxes

-
Dropdown (Select)

-
Textarea

-
Submit Button

How a Form Works (Step-by-Step)
-
User fills out the form on the website
-
They click the Submit button
-
The browser sends the data to the server using the URL in the
action
attribute -
The server receives and processes the data (e.g., saving it in a database or sending an email)
Important Tips for Beginners
-
Always include the
name
attribute on input fields—it’s what the server reads. -
Use
placeholder
text to guide users on what to enter. -
Always use labels for accessibility.
-
Always validate inputs either through HTML (
required
,type
, etc.) or JavaScript.