The <input> Tag

Use the <input> tag to define any one of a number of common form “controls,” as they are called in the HTML and XHTML standards, including text fields, multiple-choice lists, clickable images, and submission buttons. Although there are many attributes for the <input> tag, only the name attribute is required for each element (but not for a submission or reset button; see the following explanation). And as we describe in detail later, each type of input control uses only a subset of the allowed attributes. Additional <input> attributes may be required based upon which type of form element you specify.

Table 9-1 summarizes the various form <input> types and attributes, required and optional.

Table 9-1. Required and some common form element attributes

Form tag or <input> type

Attributes (× = required; ▴ = optional; blank = not supported)

accept

accesskey

align

alt

border

cols

checked

disabled

maxlength

multiple

name

notab

onBlur

onChange

onClick

onFocus

onSelect

readonly

rows

size

src

tabindex

taborder

usemap

value

wrap

button

 

     

  

×

 

     

 

×

 

checkbox

 

    

  

×

  

  

   

 

×

 

file

     

 

×

 

 

 

 

 

hidden

          

×

             

×

 

image

 

  

  

  

     

×

  

password

 

     

 

×

 

 

 

×

 

radio

 

    

  

×

  

  

   

 

×

 

reset

 

     

   

  

      

 

 

submit

 

     

  

  

      

 

 

text

 

     

 

×

 

 

 

 

<button>

 

     

  

×

 

 

     

  

 

<select>

       

 

×

 

   

 

    

<textarea>

 

   

 

  

×

 

  

   

Get HTML & XHTML: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.