HTML Form
HTML Form
The most used form tag is the <input> tag. This is the most used tag within HTML forms. It give you
to specify various types of user information fields such as text, checkboxes, radio buttons, Select
Lists, Submit etc.
Attributes Value Description
There are different types of form controls that you can use to collect data using HTML form −
Attributes
3
cols
Indicates the number of columns of text area box
Checkbox Control
Checkboxes are used when more than one option is required to be selected. They are also created
using HTML <input> tag but type attribute is set to checkbox.
Attributes
1
type
Indicates the type of input control and for checkbox input control it will be set to checkbox..
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
The value that will be used if the checkbox is selected.
4
checked
Set to checked if you want to select it by default.
Radio buttons are used when out of many options, just one option is required to be selected. They are
also created using HTML <input> tag but type attribute is set to radio.
Attributes
1
type
Indicates the type of input control and for checkbox input control it will be set to radio.
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
3
value
The value that will be used if the radio box is selected.
4
checked
Set to checked if you want to select it by default.
A select box, also called drop down box which provides option to list down various options in the
form of drop down list, from where a user can select one or more options.
Attributes
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
size
This can be used to present a scrolling list box.
3
multiple
If set to "multiple" then allows a user to select multiple items from the menu.
1
value
The value that will be used if an option in the select box box is selected.
FORM TAG AND HTML COMMENTS
2
selected
Specifies that this option should be the initially selected value when the page loads.
3
label
An alternative way of labeling options
If you want to allow a user to upload a file to your web site, you will need to use a file upload box,
also known as a file select box. This is also created using the <input> element but type attribute is set
to file.
Attributes
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
accept
Specifies the types of files that the server accepts.
Button Controls
There are various ways in HTML to create clickable buttons. You can also create a clickable button
using <input>tag by setting its type attribute to button. The type attribute can take the following
values −
1
submit
This creates a button that automatically submits a form.
2
reset
This creates a button that automatically resets form controls to their initial values.
3
button
FORM TAG AND HTML COMMENTS
This creates a button that is used to trigger a client-side script when the user clicks that button.
4
image
This creates a clickable button but we can use an image as background of the button.
Hidden form controls are used to hide data inside the page which later on can be pushed to the server.
This control hides inside the code and does not appear on the actual page. For example, following
hidden form is being used to keep current page number. When a user will click next page then the
value of hidden control will be sent to the web server and there it will decide which page will be
displayed next based on the passed current page
Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes −
1
action
Backend script ready to process your passed data.
2
method
Method to be used to upload data. The most frequently used are GET and POST methods.
3
target
Specify the target window or frame where the result of the script will be displayed. It takes
values like _blank, _self, _parent etc.
FORM TAG AND HTML COMMENTS
Definition
HTML comment tag use to insert a comment into a source code. It's good habit to
write a comment into a source code to improve user readability and understands.
You can also write a specify information inside comments. In this case they will not
be display on web document and not visible for the user.
A good habit is write comment text inside html pages, scripts and style elements.
Comment Tag does not support any Standard Attributes.