XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / input

(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

   

input

HTML 4.01 | HTML 5

HTML: <input>; XHTML: <input/> or <input />

The element input creates various input controls. The control type is defined by the attribute type. Below is a complete list of attributes and descriptions for the input element. Not every attribute applies to every control type. Attributes for individual controls are listed below.

Notes

HTML 5 defines several new values for the attribute type: datetime, datetime-local, date, month, week, time, number, range, email, url, search and color. New HTML 5 attributes for the input element appear in the list below.

Start/end tag

This is an empty element. HTML forbids an end tag. In XHTML, the element must end with a slash before the closing angle bracket. Developers can insert a space before the slash to improve backward compatibility with older browsers.

Attributes

Core, Internationalization, events, focus; additionally: onselect, onchange, global HTML 5 attributes

  • accept="Liste mit MIME-Typen"

    Contains a comma-separated list of content types (MIME types) supported by the server processing the form. This can filter out unsuitable formats when users are asked to upload files.

  • accesskey="Zeichen"

    Assigns a keyboard shortcut for faster access to the element.

  • align="bottom|left|middle|right|top"

    Deprecated. Not in HTML 5. Specifies an image’s alignment.

  • alt="Text"

    Contains alternative text if a button’s image cannot be displayed.

  • autocomplete="on|off"

    HTML 5 only. Allows the user agent (browser) to fill the field automatically (on), or requires users to enter information each time (off). If omitted, the control inherits the setting for autocomplete from the associated, usually containing, form element.

  • autofocus (autofocus="autofocus" in XHTML)

    HTML 5 only. Makes the control receive focus automatically on loading: it is highlighted and ready for input.

  • checked (checked="checked" in XHTML)

    Makes a radio button or checkbox automatically selected when the page loads.

  • disabled (disabled="disabled" in XHTML)

    Disables user input in the control. Only a script can change this. Browsers may display disabled controls differently, for example grayed out. This can keep parts of a form unavailable until certain information has been entered.

  • form="ID des übergeordneten Formulars"

    HTML 5 only. Explicitly associates the control with its parent form. The control therefore need not be a child of the corresponding form element.

  • formaction="URL"

    HTML 5 only. Refers to the program processing the form. Used only with a submit button (type="submit" or type="image") and has the same function as the attribute action for the form element.

  • formenctype="Inhaltstyp"

    HTML 5 only. Specifies how form values are encoded when using the HTTP method post. Used only with a submit button (type="submit" or type="image") and has the same function as the attribute enctype for the form element. The default Internet media type is (application/x-www-form-urlencoded). The value multipart/form-data should be used with the input type file.

  • formmethod="get|post|put|delete"

    HTML 5 only. Specifies the HTTP method for submitting form data. Used only with a submit button (type="submit" or "image") and has the same function as the attribute method for the form element. The values put and delete are new in HTML 5

  • formnovalidate (formnovalidate="formnovalidate" in HTML 5)

    HTML 5 only. Specifies that the form should not be validated on submission. Used only with a submit button (type="submit" or "image") and has the same function as the attribute novalidate for the form element, new in HTML 5.

  • formtarget="Name"

    HTML 5 only. Specifies the window displaying the form’s results. Used only with the submit button (type="submit" or "image") and has the same function as the target attribute for the form element.

  • height="Anzahl der Pixel"

    HTML 5 only. Defines the button image’s height when the attribute type has the value image.

  • ismap (autofocus="autofocus" in XHTML)

    Not available in HTML 5. Specifies that the image is a server-side image map containing multiple hyperlinks. Can be used only when the attribute type has the value image.

  • list="Id des datalist-Elements"

    HTML 5 only. Indicates that predefined suggestions are available to the user through the element datalist. The value of the list attribute is the ID of the corresponding datalist element.

  • max="Zahl oder Zeichenkette"

    HTML 5 only. Specifies the maximum when values must lie within a range. The value of max must not be less than that of min.

  • maxlength="Zahl"

    Specifies the maximum number of characters the user can enter when the attribute type has the value text, password, search, tel or url.

  • min="Zahl oder Zeichenkette"

    HTML 5 only. Sets a minimum when input values must lie within a range. The value of min also defines the base for step operations.

  • multiple (multiple="multiple" in XHTML)

    HTML 5 only. Specifies that the user can enter more than one value, for example in selection lists.

  • name="Text"

    Required for all input types except submit and reset. Assigns a name through which scripts can access the control.

  • pattern="Regulärer Ausdruck in JavaScript-Schreibweise"

    HTML 5 only. Defines a regular expression for validating the control’s value. This is useful when input must follow a format, such as a phone number or email address. The attribute title can provide pattern with a description of the regular expression or input format.

  • placeholder="Zahl oder Zeichenkette"

    HTML 5 only. Contains a short hint, a word or short sentence, to help users enter the right data or format. Longer descriptions should use the attribute title. The attribute placeholder must not contain line breaks.

  • readonly (readonly="readonly" in XHTML)

    The user cannot modify this input element.

  • required (required="required" in XHTML)

    HTML 5 only. Specifies that a value must be entered.

  • size="Zahl"

    Defines the width of a text field in characters when type has the value text, password or search. If the text exceeds the specified width, the content scrolls to the right.

  • src="URL"

    If the input type image is used, this attribute specifies the location of the button image.

  • step="any|Zahl|Zeichenkette"

    HTML 5 only. Defines the required step size by restricting input to allowed increments. Its value depends on the content type (type) used. It can be a number, a string such as a date, or the keyword any which permits any value.

  • tabindex="Zahl"

    Defines the position in the tab order, allowing users to move between active form fields with the Tab key.

  • type="text|password|checkbox|radio|submit|reset|file|hidden|image|button" 
    New in HTML 5: "date|datetime|datetime-local|email|month|number|range|tel|time|url|week"

    Specifies the control’s content type, such as button or text field. Descriptions of each type appear in the list below.

  • usemap="URL"

    Not available in HTML 5. Specifies the address of the coordinates and links for a client-side image map, an image containing multiple hyperlinks. This attribute can be used only with the content type (type) image.

  • value="Text"

    Defines the control’s initial value.

  • width="Anzahl der Pixel"

    HTML 5 only. Specifies the width of the button image when the content type image is used.

input type="button"

Creates a customizable button. Such buttons have no predefined behavior but can trigger functions provided by JavaScript, for example. Data associated with controls of type button are never sent to the server when the user submits the form. They are used exclusively by scripts in the browser:

 <input type="button" value="Klick mich an!"> 

Core, internationalization, events, focus, global HTML 5 attributes

align="left|middle|right|top|bottom" (Deprecated. Not in HTML 5.)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

name="text" (Required)

value="Text"

input type="checkbox"

Creates a checkbox within a form (form). Checkboxes act as on/off switches. Multiple checkboxes in a group can be selected at once. On submission, only selected checkbox values are sent to the server:

<p>Welche der folgenden Betriebssysteme benutzen Sie?</p>
<ul> 
<li><input type="checkbox" name="os" value="Win">Windows</li> 
<li><input type="checkbox" name="os" value="Linux" checked="checked">Linux</li> 
<li><input type="checkbox" name="os" value="OSX" checked="checked">Mac OS X</li> 
<li><input type="checkbox" name="os" value="DOS">DOS</li> 
</ul>

Core, internationalization, events, focus, global HTML 5 attributes

align="left|middle|right|top|bottom" (Deprecated. Not in HTML 5.)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

checked (checked="checked" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

name="text" (Required)

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML) (HTML 5 only)

value="text" (Required)

input type="color"

This content type and its attributes are used only in HTML 5.

Creates a color palette for selecting a color:

 <input type="color" value="3D458A"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

name="Name"

value="Text"

input type="date"

This content type and its attributes are used only in HTML 5.

Creates a date control, such as a calendar displayed when needed, for entering a year, month and day without a time zone. The initial value must be a date in ISO format:

 <input type="date" name="Geburtstag" value="2004-01-14"> 

Global HTML 5 attributes

autofocus (autofocus="autofocus" in XHTML)

autocomplete="on|off"

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="YYYY-MM-DD"

input type="datetime"

This content type and its attributes are used only in HTML 5.

Creates a combined date and time control. The date and time value must use ISO format. It is defined as UTC, formerly GMT, and must be transmitted accordingly:

 <input type="datetime" name="post" value="2004-01-14T18:05:32:00Z"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="YYYY-MM-DDThh:mm:ssTZD"

input type="datetime-local"

This content type and its attributes are used only in HTML 5.

Creates a combined date and time control, assuming the time refers to the local time zone. Initial values must use ISO format. They are defined as UTC, formerly GMT, and must be transmitted accordingly:

 <input type="datetime-local" name="post" value="2009-06-23T13:44:16:00"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="YYYY-MM-DDThh:mm:ss"

input type="email"

This content type and its attributes are used only in HTML 5.

Creates a text field for one or more email addresses. The user agent (browser) can check the input against patterns to ensure it is a valid email address:

 <input type="email" name="post" value="jan@example.com"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

maxlength="Zahl"

multiple (multiple="multiple" in XHTML)

pattern="Regulärer Ausdruck in JavaScript-Schreibweise"

placeholder="Text"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

size="Zahl"

value="Text"

input type="file"

Provides a file selection mechanism so users can send local files to the server through the form:

<form enctype="multipart/form-data">
<p>Diese Datei mit meinen Formulardaten verschicken:<br>
<input type="file" name="Anhang" size="28">
</p>
</form>

Core, internationalization, events, focus, global HTML 5 attributes

accept="MIME type"

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

maxlength="Zahl"

multiple (multiple="multiple" in XHTML) (HTML 5 only)

name="text" (Required)

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML) (HTML 5 only)

size="Zahl"

value="Text"

input type="hidden"

Creates a control not displayed in the browser. Hidden controls can send information needed to process the form that the user should neither see nor change:

 <input type="hidden" name="Katalognummer" value="12-XL"> 

Global HTML 5 attributes

accesskey="Zeichen"

disabled (disabled="disabled" in XHTML) (HTML 5 only)

form="ID des übergeordneten Formulars" (HTML 5 only)

name="Text" (Required)

tabindex="Zahl" (Not available in HTML 5)

value="Text" (Required)

input type="image"

Allows an image to replace a submit button with a graphic (type="submit"). Clicking a button with the content type type="image" submits the form:

 <input type="image" src="graphics/abschicken.gif" alt="Abschicken"> 

Core, internationalization, events, focus, global HTML 5 attributes

align="top|middle|bottom" (Not available in HTML 5)

alt="text" (Not available in HTML 5)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

formaction="URL" (HTML 5 only)

formenctype="content type" (HTML 5 only)

formmethod="get|post|put|delete" (HTML 5 only)

formnovalidate (formnovalidate="formnovalidate" in XHTML) (HTML 5 only)

formtarget="Name" (HTML 5 only)

height="Höhe der Grafik in Pixeln" (HTML 5 only)

ismap (ismap="ismap" in XHTML)

name="Text"

src="URL"

usemap="URL"

width="Breite der Grafik in Pixeln" (HTML 5 only)

input type="month"

This content type and its attributes are used only in HTML 5.

Creates a date field, such as a calendar displayed when needed, for specifying a month of the year:

 <input type="month" value="2009-09" name="Vertragsende"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="YYYY-MM"

input type="number"

This content type and its attributes are used only in HTML 5.

Creates a numeric input control, such as a text field or spinner:

 <input type="number" name="Preis" minimum="100000" max="1000000" step="10000"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl"

min="Zahl"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="Text oder Zahl"

input type="password"

Creates a text field, like <input type="text">. However, the actual characters are hidden and replaced by dots or asterisks (*). The information is not encrypted, so this field does not increase security:

 <input type="password" name="Passwort" size="8"maxlength="8" value="abcdefg"> 

Core, internationalization, events, focus, global HTML 5 attributes

autocomplete="on|off" (HTML 5 only)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

maxlength="Zahl"

name="text" (Required)

pattern="Regulärer Ausdruck in JavaScript-Schreibweise" (HTML 5 only)

placeholder="text" (HTML 5 only)

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML) (HTML 5 only)

size="Zahl"

value="Text"

input type="radio"

Creates a radio button that can be switched on or off. Among radio buttons sharing a name, only one can be on at a time; the others are off. Unlike checkboxes, this prevents multiple selections within a group. Only active radio button data is sent to the processing program on submission:

<p>Welches der folgenden Betriebssysteme gefällt Ihnen am besten?</p>
<ul>
<li><input type="radio" name="os" value="Win">Windows</li>
<li><input type="radio" name="os" value="Linux">Linux</li>
<li><input type="radio" name="os" value="OS X" checked>Mac OS X</li>
<li><input type="radio" name="os" value="DOS">DOS</li>
</ul>

Core, internationalization, events, focus, global HTML 5 attributes

checked (checked="checked" in XHTML)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

name="Text" (Required)

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML) (HTML 5 only)

value="Text" (Required)

input type="range"

This content type and its attributes are used only in HTML 5.

Creates a slider for entering a value that need not be precise. The rangestarts with the value of the attribute min (the default is 0) and ends with the value of max (the default is 100):

 <input type="range" name="Zufriedenheit" min="0" max="10"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl"

min="Zahl"

name="Name"

step="any|Zahl"

value="Text"

input type="reset"

Creates a reset button that clears form inputs or restores their initial values:

 <input type="reset" value="Nochmal von vorne"> 

Core, internationalization, events, focus, global HTML 5 attributes

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

name="Text"

value="Text"

input type="search"

This content type and its attributes are used only in HTML 5.

Creates a single-line text field for a search query:

 <input type="search" name="suche" size="25" value="Suchbegriff eingeben"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

maxlength="Zahl"

pattern="Regulärer Ausdruck in JavaScript-Schreibweise"

placeholder="Text"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

size="Zahl"

value="Text"

input type="submit"

Creates a submit button. Clicking it sends the form’s information to the server for processing:

<p>Sie haben das Formular vollständig ausgefüllt.</p>
<p><input type="submit"></p>

Core, internationalization, events, focus, global HTML 5 attributes

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

formaction="URL" (HTML 5 only)

formenctype="Inhaltstyp" (HTML 5 only)

formmethod="get|post|put|delete" (HTML 5 only)

formnovalidate (formnovalidate="formnovalidate" in XHTML) (HTML 5 only)

formtarget="Name" (HTML 5 only)

name="Text"

value="Text"

input type="tel"

This content type and its attributes are used only in HTML 5.

Creates a field for entering and editing a phone number:

 <input type="tel" name="Telefon" value="123-555-2000"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

maxlength="Zahl"

pattern="Regulärer Ausdruck in JavaScript-Schreibweise"

placeholder="Text"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

size="Zahl"

value="Text"

input type="text"

Creates a text field. This is the default value of the attribute type and one of the most useful and popular values. Text supplied for the attribute value appears in the field when the form loads:

 <input type="text" name="Name" size="15" maxlength="50" value="Hier den Namen eingeben"> 

Core, internationalization, events, focus, global HTML 5 attributes

autocomplete="on|off" (HTML 5 only)

autofocus (autofocus="autofocus" in XHTML) (HTML 5 only)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars" (HTML 5 only)

list="ID des datalist-Elements" (HTML 5 only)

maxlength="Zahl"

name="text" (Required)

pattern="Regulärer Ausdruck in JavaScript-Schreibweise" (HTML 5 only)

placeholder="Text" (HTML 5 only)

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML) (HTML 5 only)

size="Zahl"

value="Text"

input type="time"

This content type and its attributes are used only in HTML 5.

Creates a field for entering a time, including hours, minutes, seconds and fractions of seconds, without a time zone:

 <input type="time" name="Uhrzeit" value="23:15:00"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="hh:mm:ss"

input type="url"

This content type and its attributes are used only in HTML 5.

Creates a URL field. The user agent (browser) can validate the URL format against the regular expression specified by pattern and return an error message if needed:

 <input type="url" name="Blog" size="25" value="http://www.example.com"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

maxlength="Zahl"

pattern="Regulärer Ausdruck in JavaScript-Schreibweise"

placeholder="Text"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

size="Zahl"

value="Text"

input type="week"

This content type and its attributes are used only in HTML 5.

Creates a control for specifying a week of the year, for example through a calendar. Values must follow the ISO number format:

 <input type="week" name="diesewoche" value="2009-W34"> 

Global HTML 5 attributes

autocomplete="on|off"

autofocus (autofocus="autofocus" in XHTML)

disabled (disabled="disabled" in XHTML)

form="ID des übergeordneten Formulars"

list="ID des datalist-Elements"

max="Zahl oder Zeichenkette"

min="Zahl oder Zeichenkette"

name="Name"

readonly (readonly="readonly" in XHTML)

required (required="required" in XHTML)

step="any|Zahl"

value="YYYY-W#"

back to top

   

 

> back to the alphabetical list of elements

   

 

 

 

back to top