HTML: Input Tag

By Xah Lee. Date: . Last updated: .

2018-10-23 This page is under revision

The input tag is used to generate many different types of inputs such as buttons, menu, checkboxes, search box, message box, etc.

Here's examples:

Text Field

<label for="text34521">Name:</label>
<input id="text34521" type="text" size="20" maxlength="50" name="user_name" value="Jenny">

Password Text Field

Masked text field is used for passwords. What user typed won't be shown.

<label for="pass75487">password:</label>
<input id="pass75487" type="password" size="30" maxlength="30" name="password">

Radio Button

Only one can be selected of the same name value.

<input id="radio1" type="radio" name="pets1" value="dog">
<label for="radio1">Dog</label>
<input id="radio2" type="radio" name="pets1" checked value="cat">
<label for="radio2">Cat</label>
<input id="radio3" type="radio" name="pets1" value="bird">
<label for="radio3">Bird</label>

Check Box

Single Selection Check Box

<input id="checkbox19044" type="checkbox" name="married" value="married">
<label for="checkbox19044">Married</label>

Multi Selection Check Boxes

More than one can be checked. Value is a list.
<input id="cb77316" type="checkbox" name="pets2" checked value="dog">
<label for="cb77316">Dog</label>
<input id="cb85875" type="checkbox" name="pets2" checked value="cat">
<label for="cb85875">Cat</label>
<input id="cb47400" type="checkbox" name="pets2" value="bird">
<label for="cb47400">Bird</label>

Submit Buttons

INPUT with attribute type="submit" draws submit buttons. When these buttons are pressed, the form is sent to the CGI program. The name and value attributes are optional.

Submit button 1:

<input type="submit" name="submit1">

Multiple Submit Buttons

You can have multiple submit buttons, with name and value attributes. The name attribute can be the same. The value of the value will be shown as the text on button, and is the value string sent to the server.

<input type="submit" name="license_agreement" value="agree">
<input type="submit" name="license_agreement" value="disagree">

Reset Button

The type="reset" shows a button with a special action that tells the browser to reset the form.

<input type="reset" name="reset" value="Reset">

2018-10-23 the following is work in progress


<input type="button" />


<input type="color" />


<input type="date" />


<input type="datetime-local" />


<input type="email" />


<input type="file" />


<input type="hidden" />


<input type="image" />


<input type="month" />


<input type="number" />


<input type="range" />


<input type="search" />


<input type="tel" />


<input type="time" />


<input type="url" />


<input type="week" />

back to HTML Form Example

Liket it? I spend 2 years writing this tutorial. Help me spread it. Tell your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Ref
  5. DOM Scripting
  6. SVG
  7. Blog