Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


What is a form element in HTML?

Khizar Hayat Saani

<form> is a tag in HTML that has the special purpose of passing collected information from the user of the webpage to the backend database or servers. It includes other elements enclosed between its opening (<form>) and closing (</form>) tags.


Just like any other tag in HTML, a form is associated with a name and a value. The special attributes that it entertains are the method and action attributes.

  • A method attribute specifies the type of request this form will process, e.g., a GET or POST method.
  • An action attribute specifies the path where the request is to be relayed.

A <form> may collect data using multiple elements that it supports. These elements are described in the table below.




specifies a clickable button in the form


specifies a drop-down menu


groups related elements and draws a box around them


defines the location and medium of user input


encrypts the data being forwarded to the server


gives a boundary to the user interaction area


defines a caption for a fieldset


specifies a selection list to choose from


specifies a data output location


specifies a drop-down list


specifies a multi-line text box

You can collect data using any of the elements in the aforementioned list according to your needs.

The data inside the form has an initial value, and the user may choose to change it and submit the form.


In the example below, we will implement a simple form that inputs the username and password and allows us to choose between login and sign up.




Khizar Hayat Saani
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring