INPUT element is a useful HTML form tag to know because it is one of the most flexible. The input tag prompts your readers to input data to your web server. It offers many different ways to solicit content from your users.
There are ten specific types of
INPUT tag in HTML 4.01 and HTML5 adds 13 new ones. the HTML 4.01 types are:
You choose which type of input tag you would like by placing it in the
type="" attribute of the tag. For example:
<input type="button" value="button" name="button">
With a checkbox element, you can give your readers a list of items to choose from. They can choose more than one in the list. Or it can be used as a "yes/no" toggle, when there is only one option. If you have a group of checkboxes, link them all together by giving them the same name. The values will all be sent to the form separately.
The file input type allows your readers to upload a file to your web server. If you read my article on CGIs and File Upload, you can learn more about how to use the file input type.
Hidden fields are used to "save state" within an HTML form. They are most often used in forms that have multiple pages and information that needs to be carried from one page to the next. They are not shown on the Web page, but the information is sent along with other form input fields.
<input type="image" src="ABCbuttn.gif" width="88" height="31" alt="About.com - image courtesy About.com" border="0">
With the image input type, you have yet another option for a button on your forms. The image shown here happens to look like a button, but you can use any image as a button on your forms. One thing to note, images as submit buttons don't allow for the tab key to move the focus to it, and this makes them less accessible for people with no mouse.
The password field looks almost identical to the text field. However, when you type in it, the letters are hidden. This allows you to have a little more security for passwords on your forms. The passwords are not sent encrypted in any way. So don't rely on this to secure truly important secret information.
Radio buttons give readers a "one of many" choice combination. Like the checkbox input type, radio button groupings all have the same
name attribute, and each value is different. If a reader chooses one value, all the other values will be deselected.
The reset button resets the form to its default value. With most forms, this is blank entries, but if the fields have starting values, the reset button will return the form to that. This "resetting" is done by the browser, not the server. This button will have the default value of "Reset", if you want it to say something different, change the
In order for a form to be sent to the server it needs some form of submit button. This field sends the form information to the web server when it is clicked. In Internet Explorer it has a default value of "Submit" and in Firefox of "Submit
Query". If you want to change this, change the
The text box is the most common input type and to make HTML easier, is the default for the input tag. This tag lets your readers type inany text information into the box. Text input fields are typically one line long. If you need a longer text field, you should use the textarea tag.
This article is part of the HTML Forms Tutorial