The XHTML WYSIWYG Editor For Desktop & Web Applications

input

Definition

The input element is a multi-purpose form control. The type attribute specifies the type of form control to be created.

Example

  1. <form method="post" action="register.php">
  2. <fieldset>
  3. <legend>Personal information</legend>
  4. <label for="firstname">First name</label><br />
  5. <input type="text" name="firstname" id="firstname" /><br />
  6. <label for="lastname">Last name</label><br />
  7. <input type="text" name="lastname" id="lastname" />
  8. </fieldset>
  9. <fieldset>
  10. <legend>Medical history</legend>
  11. <input name="history" type="checkbox" value="1" id="smallpox" />
  12. <label for="smallpox">Smallpox</label><br />
  13. <input name="history" type="checkbox" value="2" id="mumps" />
  14. <label for="mumps">Mumps</label><br />
  15. <input name="history" type="checkbox" value="3" id="dizziness" />
  16. <label for="dizziness">Dizziness</label>
  17. </fieldset>
  18. <p>
  19. <input type="submit" name="action" value="Register" />
  20. <input type="reset" value="Reset Form" />
  21. <input type="hidden" name="session" value="A398DF991" />
  22. </p>
  23. </form>

Attributes

Basic

alt
(Text) Alternate text for controls of the type image.
checked
When the type attribute has the value radio or checkbox, this attribute specifies that the radio/checkbox is selected.
maxlength
(Number) When the type attribute has the value text or password, this attribute specifies the maximum number of characters the user may enter. This number should not exceed the value specified in the size attribute.
name
(Text) Form control name.
size
(Number) This attribute tells the Web browser the initial width of the control. The width is given in pixels except when the type attribute has the value text or password. In such cases, its value is the number of characters.
type

Type of control to create. Possible values are:

text
Creates a single-line text input control.
password
Creates a single-line text input control with masked input (characters appear as asterisks). Note, this control hides what the user is typing from casual observers (someone looking over your shoulder) but provides no more security than any other form control.
checkbox
Creates a checkbox.
radio
Creates a radio button.
submit
Creates a submit button.
image
Creates a graphical submit button. Alternate text should be provided via the alt attribute.
reset
Creates a reset button which restores the value of all controls on the form to their initial state.
button
Creates a push button.
hidden
Creates a hidden control. Hidden controls are useful for passing additional information back and forth between the server and the Web browser.
file
Creates a file select control for uploading files.
value
(Text) Value associated with a control.

Advanced

accept
(ContentTypes) This attribute specifies a comma-separated list of content types that a server processing this form will handle correctly.
accesskey
(Character) Accessibility key character.
disabled
Disables the control for user input. Possible value is disabled.
ismap
If present, this attribute specifies that a server-side image map should be used. Possible value is ismap.
onblur
(Script) A client-side script event that occurs when an element loses focus either by the pointing device or by tabbing navigation.
onchange
(Script) A client-side script event that occurs when a control loses the input focus and its value is modified prior to its next receiving focus.
onfocus
(Script) A client-side script event that occurs when an element receives focus either by the pointing device or by tabbing navigation.
onselect
(Script) A client-side script event that occurs when a user selects some text in a text field.
readonly
If present, this attribute prohibits changes to the value in the control. Possible value is readonly.
src
(URI) When the type attribute has the value image, this attribute specifies the location of the image to be used to decorate the graphical submit button.
tabindex
(Number) Position in tabbing order.
usemap
(IDReference) When the type attribute has the value image, this attribute associates the image to a client-side image map defined by a map element. The value of this attribute must match the id attribute of the map element.

Common core attributes

class
(NameTokens) This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or set of class names. Multiple class names must be separated by white space characters. Class names are typically used to apply CSS formatting rules to an element.
id
(ID) This attribute assigns an ID to an element. This ID must be unique in a document. This ID can be used by client-side scripts (such as JavaScript) to select elements, apply CSS formatting rules, or to build relationships between elements.
title
(Text) This attribute offers advisory information. Some Web browsers will display this information as tooltips. Assistive technologies may make this information available to users as additional information about the element.

Common internationalization attributes

xml:lang
(NameToken) This attribute specifies the base language of an element's attribute values and text content.
dir

This attribute specifies the base direction of text. Possible values:

  • ltr: Left-to-right
  • rtl: Right-to-left

Common event attributes

onclick
(Script) A client-side script event that occurs when a pointing device button is clicked over an element.
ondblclick
(Script) A client-side script event that occurs when a pointing device button is double-clicked over an element.
onmousedown
(Script) A client-side script event that occurs when a pointing device button is pressed down over an element.
onmouseup
(Script) A client-side script event that occurs when a pointing device button is released over an element.
onmouseover
(Script) A client-side script event that occurs when a pointing device is moved onto an element.
onmousemove
(Script) A client-side script event that occurs when a pointing device is moved within an element.
onmouseout
(Script) A client-side script event that occurs when a pointing device is moved away from an element.
onkeypress
(Script) A client-side script event that occurs when a key is pressed down over an element then released.
onkeydown
(Script) A client-side script event that occurs when a key is pressed down over an element.
onkeyup
(Script) A client-side script event that occurs when a key is released over an element.

Common style attribute

style
(Text) This attribute specifies formatting style information for the current element. The content of this attribute is called inline CSS. The style attribute is deprecated (considered outdated), because it fuses together content and formatting.

Contains

  • Nothing

See also