The `

Before diving into the tag's attributes and uses, let's start with a basic example of how to use the `

Basic Structure of the `
The `
` tag. The content between these two tags is the form that users can interact with.
Here's a simple form example with a text input and a submit button:
<form>
<label for="fname">First name</label>
<input type="text" id="fname" name="fname">
<input type="submit" value="Submit">
</form>
Attributes of the `

The `
-
action: Specifies the URL to which the form-data will be submitted. If this attribute is not specified, the form will not submit anywhere.
<form action="/submit_form"> -
method: Specifies the HTTP method used to submit the form-data: `get` or `post`. The default method is `get`.
<form action="/submit_form" method="post">
Nesting Form Elements

Inside the `
<form action="/submit_form" method="post">
<label for="fname">First name</label>
<input type="text" id="fname" name="fname">
<label for="lname">Last name</label>
<input type="text" id="lname" name="lname">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<input type="submit" value="Submit">
</form>
Form Validation
You can include `required`, `minlength`, `maxlength`, and other attributes on input fields within the form to validate user input. Here's an example:

-
required: Ensures that the user must fill in the field.
<input type="text" id="fname" name="fname" required> -
minlength and maxlength: Set the minimum and maximum lengths for the user input, respectively.
<input type="text" id="fname" name="fname" minlength="3" maxlength="50">
Using `




















To group related form elements and improve accessibility, use the `
<fieldset>
<legend>Contact Information</legend>
...
</fieldset>
Multipart Forms and ``
To allow users to upload files, use the `` tag with `type="file"`. To send the form-data as multipart (required for file uploads), include the `enctype="multipart/form-data"` attribute in the `
Here's an example of a multipart form with a file upload field:
<form action="/upload_file" enctype="multipart/form-data">
<input type="file" id="myFile" name="myFile">
<input type="submit">
</form>
In conclusion, the `