An HTML form is used to collect user input.
action
attribute defines the action to be performed when the form is submitted.method
attribute specifies the HTTP method to be used when submitting the form data. The form-data can be sent as URL variables (with method="get"
) or as HTTP post transaction (with method="post"
).The HTML <form>
element can contain one or more of the following form elements:
<input>
- The <input>
element can be displayed in several ways, depends type
of attribute.<label>
- The <label>
element defines a label for several form elements.<textarea>
-The <textarea>
element defines a multi-line input field<button>
- The <button>
element defines a clickable button<fieldset> and <legend>
-The <fieldset>
element is used to group related data in a form. The <legend>
element defines a caption for the <fieldset>
element.<datalist>
- The <datalist>
element specifies a list of pre-defined options for an <input>
element.Users will see a drop-down list of the pre-defined options as they input data.The list
attribute of the <input>
element, must refer to the id
attribute of the <datalist>
element.<option>
-The <option>
tag defines an option in a select list.<select>
-The <select>
element defines a drop-down list.<meter> and <progress>
- show progress or range needs value attribute and max attribute.Here are the different input types you can use in HTML: