HTML Tags

HTML <form> Tag

The <form> tag is used to create an HTML form for collecting user input.
It acts as a container for various input elements like text fields, checkboxes, radio buttons, buttons, and more.
Forms are essential for user interaction — for example, submitting login details or feedback.

Syntax

<form action="submit.php" method="post" target="_blank" enctype="multipart/form-data" autocomplete="on">
   <!-- form elements go here -->
</form>

Attributes

AttributeDescription
actionSpecifies where to send the form data when submitted.
methodDefines how the form data is sent — either GET or POST.
targetSpecifies where to display the response after submitting (_blank, _self, etc.).
enctypeSpecifies how the form data should be encoded when submitted.
autocompleteEnables or disables autocomplete feature.
novalidateDisables HTML5 form validation.
nameAssigns a name to the form.
relSpecifies the relationship between the current document and the linked resource.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Form Example</title>
</head>
<body>
  <h2>Registration Form</h2>
  <form action="/samples/form_processor.php" method="post" enctype="multipart/form-data">
    <label for="name">Full Name:</label><br>
    <input type="text" id="name" name="fullname" placeholder="Enter your name" required><br><br>

    <label for="email">Email:</label><br>
    <input type="email" id="email" name="email" required><br><br>

    <label for="file">Upload Photo:</label><br>
    <input type="file" id="file" name="photo"><br><br>

    <input type="submit" value="Register">
  </form>
</body>
</html>

Output

Browser Output

You’ll see a registration form with input fields for name, email, and photo upload.
Once filled, clicking Register will open a new tab (because of target="_blank") showing the submission result.
Use our TryIt Editor to test this behavior interactively.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

The <form> element itself doesn’t produce any visible output until form controls are added inside it.

Notes

  • The <form> tag itself does not produce visible output — the contained elements do.
  • Always validate user input for security.
  • Use HTTPS when submitting sensitive data.

Conclusion

The <form> tag is the foundation of web interactivity, allowing users to submit data efficiently and securely.
It’s one of the most essential building blocks for any web application.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend