input tag (XHTML 1.1)

form control

Topics

The input tag serves as a common tag for several types of form elements. By using the type attribute, you specify which kind of control you want. The most common is the text type, which is rendered as a singleline text input field. Here's an example:

 

<input type="text" name="textbox1" />

In your browser, code like that will be rendered like this:

 

 

The type attribute

The type attribute allows the input tag to be a multipurpose tag for rendering different types of controls.

 

text

A standard input field for single lines of text:

password

Just like the text box, but characters are masked:

hidden

A hidden text box, for submitting invisible information along with the form (you can see it in the source):

checkbox

A checkbox allows the user to select multiple choices: Checkbox

radio

A radiobutton allows the user to select between a range of values: Radiobutton

submit

A submit control will submit the surrounding form:

reset

A reset control will reset all the fields of the surrounding form to the initial value:

button

A button control won't do anything by it self, and is mostly used for scripting purposes:

image

An image control allows you to create a button rendered as an image, using the src attribute:

file

The file control is for doing file uploads. The control only allows the user to select a local file - you will have to handle the processing of the file yourself:

 

Attributes

Attribute Deprecated Required Description
accept  list of MIME types for file upload 
alignX vertical or horizontal alignment 
alt  short description 
checked  for radio buttons and check boxes 
class  space-separated list of classes 
dir  direction for weak/neutral text 
disabled  unavailable in this context 
id  document-wide unique id 
ismap  use server-side image map 
lang  language code 
maxlength  max chars for text fields 
name  submit as part of form 
readonly  for text and passwd 
size  specific to each type of field 
src  for input fields with images 
style  associated style info 
tabindex  position in tabbing order 
title  advisory title 
type  specifies the type of input control to be rendered 
usemap  use client-side image map 
value  Specify for radio buttons and checkboxes 

Events

Event Description
onblurthe element lost the focus 
onchangethe element value was changed 
onclicka pointer button was clicked 
ondblclicka pointer button was double clicked 
onfocusthe element got the focus 
onkeydowna key was pressed down 
onkeypressa key was pressed and released 
onkeyupa key was released 
onmousedowna pointer button was pressed down 
onmousemovea pointer was moved within 
onmouseouta pointer was moved away 
onmouseovera pointer was moved onto 
onmouseupa pointer button was released 
onselectsome text was selected 



© htmlpedia.net 2008 - 2012