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.

<div>
<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>
</div>

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.
<div>
<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>
</div>

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

button

<input type="button" />

color

<input type="color" />

date

<input type="date" />

datetime-local

<input type="datetime-local" />

email

<input type="email" />

file

<input type="file" />

hidden

<input type="hidden" />

image

<input type="image" />

month

<input type="month" />

number

<input type="number" />

range

<input type="range" />

search

<input type="search" />

tel

<input type="tel" />

time

<input type="time" />

url

<input type="url" />

week

<input type="week" />

back to HTML Form Example

Liket it? 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 Reference
  5. DOM
  6. SVG
  7. Web Dev Blog