Learn HTML – Part 37 – form Tag – Creating HTML Forms
The HTML form tag is used to create forms that collect user input on a webpage.
Forms allow users to submit information such as names, emails, passwords, and other data.
What is the form Tag?
The form tag defines an HTML form used to collect user input.
It acts as a container for various form elements such as input fields, buttons, dropdowns, and text areas.
Basic Syntax
<form>
Form elements go here
</form>
Example – Simple HTML Form
<form>
Name:<br>
<input type="text">
<br><br>
Email:<br>
<input type="email">
<br><br>
<input type="submit" value="Submit">
</form>
Output:
Important form Attributes
| Attribute | Description |
|---|---|
action | Specifies where the form data is sent |
method | Defines how the data is submitted (GET or POST) |
Example – Form with Action and Method
<form action="submit.php" method="post">
Name:<br>
<input type="text" name="username">
<br><br>
<input type="submit" value="Submit">
</form>
Common Form Elements
input– Creates input fieldslabel– Defines labels for inputstextarea– Creates multi-line text inputselect– Creates dropdown listsbutton– Creates clickable buttons
The
formelement acts as a container for all user input fields.
Why Use HTML Forms?
- Collect user information
- Create login or registration pages
- Build contact forms
- Submit data to a server
Common Mistakes Beginners Make
- Forgetting to add the
nameattribute to inputs - Not specifying the form action
- Using incorrect input types
Conclusion
The HTML form tag is used to create forms that collect user input.
It works together with elements like input, label, and button to build interactive web forms.
What’s Next?
Now that you understand the form tag, the next step is learning about the input tag, which is used to create different types of input fields inside HTML forms.
Next: Learn HTML – Part 38 – input Tag – Input Fields →
Series: Learn HTML Series
