Here are some of the key attributes that can be used with the <form> element:
- action: This attribute specifies where to send the form-data when a form is submitted. The value of this attribute is typically a URL.
- method: This attribute defines the HTTP method used to send the form-data. The values can be “get” or “post”.
- target: This attribute specifies where to display the response received after submitting the form. The values can be “_blank”, “_self”, “_parent”, “_top”, or the name of an iframe.
- enctype: This attribute is used when method=“post”. It specifies how the form-data should be encoded when submitting it to the server. The values can be “application/x-www-form-urlencoded”, “multipart/form-data”, or “text/plain”.
- autocomplete: This attribute specifies whether a form should have autocomplete on or off. When autocomplete is on, the browser automatically completes values based on values that the user has entered before.
- novalidate: This Boolean attribute specifies that the form-data should not be validated on submission.
Form Elements
|
|
|
|
Elements |
|
|
|
|
|
|
|
|
<label> |
It defines labels for <form> elements. |
|
|
|
|
<input> |
It is used to get input data from various types such as text, password, email, etc by changing its type. |
|
|
|
|
<button> |
It defines a clickable button to control other elements or execute a functionality. |
|
|
|
|
<select> |
It is used to create a drop-down list. |
|
|
|
|
<textarea> |
It is used to get input long text content. |
|
|
|
|
<fieldset> |
It is used to draw a box around other form elements and group the related data. |
|
|
|
|
<legend> |
It defines a caption for fieldset elements |
|
|
|
|
<datalist> |
It is used to specify pre-defined list options for input controls. |
|
|
|
|
Elements |
|
|
|
|
|
|
|
|
<output> |
It displays the output of performed calculations. |
|
|
|
|
<option> |
It is used to define options in a drop-down list. |
|
|
|
|
<optgroup> |
It is used to define group-related options in a drop-down list. |