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

Whether you're new to XML or already an advanced user,
the user-friendly views and powerful entry helpers,
wizards, and debuggers in XMLSpy are designed to meet your XML
and Web development needs from start to finish.
New features in Version 2010!
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- XBRL validator, taxonomy editor, taxonomy wizard
- Support for Office Open XML (OOXML)
- Graphical WSDL 1.1/2.0 editor & SOAP debugger
- JSON editing & conversion
- Java, C#, C++ code generation
- And much more!
Download a free trial today!
|
|
|
|