W3Schools.com

HTML <input> type Attribute

HTML input Tag Reference HTML <input> tag

Example

An HTML form with two different input types; text and submit:

<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)

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The type attribute is supported in all major browsers.


Definition and Usage

The type attribute specifies the type of <input> element to display.

The default type is: text.

Tip: This is not a required attribute, but we think you should always include it.


Syntax

<input type="value" />

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 resets all form fields to their initial values
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


Input type: text

Example

Define a single-line text field that a user can enter text into:

Email: <input type="text" name="email" />

Try it yourself »


Input type: button

Example

A clickable button, that activates a JavaScript when it is clicked:

<input type="button" value="Click me" onclick="msg()" />

Try it yourself »


Input type: checkbox

Example

Checkboxes let a user select one or more options of a limited number of choices:

<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 »


Input type: file

Example

Define a file-select field and a "Browse..." button (for file uploads):

<input type="file" />

Try it yourself »


Input type: hidden

Example

Define a hidden field (not visible to a user). A hidden field often store a default value, or can have its value changed by a JavaScript:

<input type="hidden" name="country" value="Norway" />

Try it yourself »


Input type: image

Example

Define an image as a submit button:

<input type="image" src="submit.gif" alt="Submit" />

Try it yourself »


Input type: password

Example

Define a password field (characters are masked)

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

Try it yourself »


Input type: radio

Example

Radio buttons let a user select only one of a limited number of choices:

<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female

Try it yourself »


Input type: reset

Tip: Use the reset button carefully! It can be annoying for users who accidentally activate the reset button.

Example

Define a reset button (resets all form values to default values):

<input type="reset" />

Try it yourself »


Input type: submit

Example

Define a submit button:

<input type="submit" />

Try it yourself »


HTML input Tag Reference HTML <input> tag
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE