HTML Forms
HTML Forms
Attributes
Attribute Description
name Assigns a name to the form. This is
used when referencing the form with
stylesheets or scripts. If there are
multiple forms, the name of each form
must be unique.
method Specifies the HTTP method to use
when the form is submitted.
Possible values:
<form >
//input controls e.g. textfield, textarea, radiobutton, b
utton
</form>
Tag Description
<form> It defines an HTML form to
enter inputs by the used
side.
<input> It defines an input control.
<textarea> It defines a multi-line input
control.
<label> It defines a label for an
input element.
<fieldset> It groups the related
element in a form.
<legend> It defines a caption for a
<fieldset> element.
<select> It defines a drop-down list.
<optgroup> It defines a group of related
options in a drop-down list.
<option> It defines an option in a
drop-down list.
<button> It defines a clickable button.
Tag Description
<datalist> It specifies a list of pre-
defined options for input
control.
<keygen> It defines a key-pair
generator field for forms.
<output> It defines the result of a
calculation.
<input> element
The HTML <input> element is fundamental form
element. It is used to create form fields, to take input
from user. We can apply different input filed to gather
different information form user. Following is the
example to show the simple text input.
1. TextField Control
The type="text" attribute of input tag creates textfield
control also known as single line textfield control. The
name attribute is optional.
<form>
<label for="email">Email: </label>
<input type="email" id="email" name="email"/> <
br/>
</form>
4. Radio Button Control
The radio button is used to select one option from
multiple options. It is used for selection of gender, quiz
questions etc.
If you use one name for all the radio buttons, only one
radio button can be selected at a time.
5. Checkbox Control
The checkbox control is used to check multiple options
from given checkboxes.
<form>
Hobby:
<input type="checkbox" id="cricket" name="cricke
t" value="cricket"/>
Cricket
<input type="checkbox" id="football" name="foot
ball" value="football"/>
Football:
<input type="checkbox" id="hockey" name="hock
ey" value="hockey"/>
Hockey:
</form>
7. Adding Button
<select>
<option></option>
</select>
2. <output> element