The input element contains the largest numbers of possible form control types there are.

Which control type is going to be used is declared by the attribute type.

The options to choose from are:

Text

Creates a single line text field. It is usually used for personal names, country names etc...

Password

Essentially same as text but the characters get masked with, i.e., series of asterisks in place of really typed text. This is protection only against somebody looking directly at it while being typed. The actual value sent to the server is the current (real) text a user typed in and therefore better means of protection will be necessary to fully protect the sensitive input.

Checkbox

On/off toggle inputs are being created and user can select none, one or more of then at the same time. Only selected checkboxes are being sent to the server. There is a possibility of having one or more boxes pre-checked with the attribute check.

Radio

Radio type creates radio buttons. They are same as checkboxes except that they share the same name attribute which makes them mutually exclusive or in other words only one in a group can be selected. The browser must ensure that the first radio button gets transmitted as "on", in case of not having any of them selected before submitting. Same as checkboxes they have a possibility of having one of them pre-checked.

Submit

Submit buttons are used to submit the form automatically. A form may have more then one submit button.

Image

Image control type basically creates a graphical submit button. After a click on it the form will also automatically get submitted but this time the server will receive the click coordinates in pixels measured from left-top of the image. The src attributes defines the URI for the image.

Reset

Resets the form to its initial values. Not needed very often.

Button

Creates a regular push button. Such a push button has no pre-defined or default behavior. It is often use to make different, usually event driven, effects. The action is defined via a server or client side scripting (such as JavaScript).

Hidden

This input type control will not be visible to client side users directly from a browser so it is often used for storing information between server and client exchanges. IT IS NOT SAFE to store sensitive data into a hidden field. That is because browsers have "see source" options that will present the data stored inside even if the user initially is not able to see it.

File

Gives an option to the users to upload and send some files and its contents to the server. The size is limited by the servers default parameters which are, unless modified by the hosting company, as low as 2MB per upload (Apache server).

Input is an empty element, therefore the closing tag is forbidden.

Syntax:

<input type="" name="" />

Attributes:

Example

HTML input element:

 

›› go to examples ››