<form> Tag in HTML
The <form> tag in HTML is used to create an HTML form for user input. It contains different form elements such as text fields, radio buttons, checkboxes, submit buttons, and more. Forms are essential for collecting data from users and submitting it to the server for processing.
Key Points on <form> Tag:
- The <form> tag wraps the form elements such as text fields, buttons, etc.
- The action attribute defines the URL where the form data will be sent when submitted.
- The method attribute specifies the HTTP method (GET or POST) for sending form data.
Syntax of <form> Tag:
Syntax Example
<form action="submit_url" method="POST">
</form>
Example of <form> Tag in HTML:
This example demonstrates how to use the <form> tag to collect a user's name and email address.
Code Example
<form action="submit_form.php" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<input type="submit" value="Submit">
</form>
Output
The <form> tag is essential for creating interactive forms that collect and submit data from users. The action attribute determines where the form data is sent, and the method attribute controls how the data is sent (e.g., using the GET or POST methods).