HTML <input> tag
The <input> tag is used to display an input field in a form and get data from the user. Input fields include textboxes, buttons, radio buttons, checkboxes, and more.
NOTE: The <input> tag has no end tag.
Attributes
| Attribute | Description | Possible values |
|---|---|---|
| accept | Specifies a list of file types that can be uploaded using the file upload input element. | MIMEtypes |
| align | Deprecated. Sets the alignment of an image in a form | left, right, top, middle, bottom |
| alt | Specifies alternative text to be displayed if the image in a form does not load | altText |
| checked | Specifies that the radio or checkbox in a form should be automatically selected when the page loads | checked |
| disabled | Specifies that an input field will be disabled (will be grayed out and the user will not be able to edit it) | disabled |
| maxlength | Specifies the maximum number of characters that a text field can have | maxCharacters |
| name | Sets the name of an input field | nameOfField |
| readonly | Specifies that a text field is read-only, meaning you can't change its content but only read what's already there | readonly |
| size | Sets the width of an input field | numericValue |
| src | Specifies the location of the image (when you're including an image in a form) | locationOfImg |
| type | Specifies what input field to display | button, checkbox, file, hidden, image, password, radio, reset, submit, text |
| value | Specifies text to be displayed by default within certain form elements. NOTE: If the type attribute is set with the value "radio" or "checkbox" then this attribute is required! |
textToDisplay |
Standard attributes
accesskey, class, dir, id, lang, style, tabindex, title, xml:lang
For more information on standard attributes, check out our HTML standard attributes reference page.
Event attributes
onfocus, onblur, onselect, onchange, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
For more information on event attributes, check out our HTML event attributes reference page.
Example
Tips & notes
Use the <label> tag to set the text of input elements in a form.
Use CSS to style input elements in many ways like setting a border, font size and color, background color, padding, and much more.