HTML <input> type Attribute
HTML <input> tag
Example
A simple HTML form with two input fields and one submit button:
<form
action="form_action.asp"
method="get">
First name: <input type="text" name="fname"
/><br />
Last name:
<input type="text" name="lname"
/><br />
<input type="submit" value="Submit" />
</form> |
Try it yourself » (more examples below) |
Definition and Usage
The type attribute specifies the type of an input element.
Browser Support

The type attribute is supported in all major browsers.
Syntax
Attribute Values
| Value |
Description |
| button |
Defines a clickable button (mostly used with a JavaScript to activate a script) |
| checkbox |
Defines a checkbox |
| file |
Defines an input field and a "Browse..." button, for file uploads |
| hidden |
Defines a hidden input field |
| image |
Defines an image as a submit button |
| password |
Defines a password field. The characters in this field are masked |
| radio |
Defines a radio button |
| reset |
Defines a reset button. A reset button clears all data from
a form |
| submit |
Defines a submit button. A submit button sends form data to a server |
| text |
Defines a one-line input field that a user can enter text into. Default width is 20 characters |
Text
<input type="text" /> defines a one-line input field that a user can enter text into.
Example
Email: <input type="text" name="email"
/><br />
Pin:
<input type="text" name="pin" /> |
Try it yourself »
|
Button
<input type="button" /> defines a clickable button, that does not do anything. The
button type is most often used to activate a JavaScript when a user clicks on the button.
Checkbox
<input type="checkbox" /> defines a checkbox. Checkboxes let a user select one or more options of a limited number of choices.
Example
<input type="checkbox" name="vehicle" value="Bike" />
I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" />
I have a car |
Try it yourself »
|
File
<input type="file" /> is used for file uploads.
Hidden
<input type="hidden" /> defines a hidden field. A hidden field is not visible
for the user. Hidden fields often store a default value, or have their value changed by a JavaScript.
Image
<input type="image" /> defines an image as a submit button.
The src and alt attribute are required with <input type="image">.
Password
<input type="password" /> defines a password field. The characters in a password field are masked (shown as asterisks or circles).
Radio
<input type="radio" /> defines a radio button. Radio buttons
let a user select only one of a limited number of choices.
Example
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female |
Try it yourself »
|
Reset Button
<input type="reset" /> defines a reset button. A reset button clears all data
in a form.
Tip: Use the reset button carefully! It can be annoying for users who accidentally activate the
reset button.
Submit
<input type="submit" /> defines a submit button. A submit button is used to
send form data to a server. The data is sent to the page specified in the form's action attribute.
Example
<form action="form_action.asp" method="get">
Email: <input type="text" name="email" /><br />
<input type="submit" />
</form> |
Try it yourself »
|
HTML <input> tag

Need an easy way to get data into XML, or transform XML to another format?
MapForce lets you map XML data to/from any combination of XML, database, flat file, Excel 2007, XBRL, or Web services data.
Then it transforms data instantly or auto-generates royalty-free data integration code for recurrent conversions.
New features in Version 2010!
Download a free, fully functional 30-day trial to experience the following features:
- Easy-to-use, graphical data mapping interface
- Instant data transformation
- XSLT 1.0/2.0 and XQuery code generation
- Java, C#, and C++ code generation
- Advanced data processing functions
- Support for all major relational databases including SQL Server, IBM DB2, Oracle, and more
- Visual Studio & Eclipse integration
Download a fully-functional trial today!
|
|
|
|