The value Attribute
The value attribute specifies the initial value for an input field:
The readonly Attribute
The readonly attribute specifies that the input field is read only (cannot be changed):
The disabled Attribute
The disabled attribute specifies that the input field is disabled.
A disabled input field is unusable and un-clickable, and its value will not be sent when submitting the form:
The size Attribute
The size attribute specifies the size (in characters) for the input field:
The maxlength Attribute
The maxlength attribute specifies the maximum allowed length for the input field:
With a maxlength attribute, the input field will not accept more than the allowed number of characters.
HTML5 added the following attributes for <input>:
- height and width
- min and max
- pattern (regexp)
and the following attributes for <form>:
The autocomplete Attribute
The autocomplete attribute specifies whether a form or input field should have autocomplete on or off.
When autocomplete is on, the browser automatically complete the input values based on values that the user has entered before.
Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.
The autocomplete attribute works with <form> and the following <input> types: text, search, url, tel, email, password, datepickers, range, and color.
An HTML form with autocomplete on (and off for one input field):
Tip: In some browsers you may need to activate the autocomplete function for this to work.
The novalidate Attribute
The novalidate attribute is a <form> attribute.
When present, novalidate specifies that the form data should not be validated when submitted.
Indicates that the form is not to be validated on submit:
The autofocus Attribute
The autofocus attribute specifies that the input field should automatically get focus when the page loads.
Let the "First name" input field automatically get focus when the page loads:
The form Attribute
The form attribute specifies one or more forms an <input> element belongs to.
Tip: To refer to more than one form, use a space-separated list of form ids.
An input field located outside the HTML form (but still a part of the form):
The formaction Attribute
The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.
The formaction attribute overrides the action attribute of the <form> element.
The formaction attribute is used with type="submit" and type="image".
An HTML form with two submit buttons, with different actions:
The formenctype Attribute
The formenctype attribute specifies how the form data should be encoded when submitted (only for forms with method="post").
The formenctype attribute overrides the enctype attribute of the <form> element.
The formenctype attribute is used with type="submit" and type="image".
Send form-data that is default encoded (the first submit button), and encoded as "multipart/form-data" (the second submit button):
The formmethod Attribute
The formmethod attribute defines the HTTP method for sending form-data to the action URL.
The formmethod attribute overrides the method attribute of the <form> element.
The formmethod attribute can be used with type="submit" and type="image".
The second submit button overrides the HTTP method of the form:
The formnovalidate Attribute
The formnovalidate attribute overrides the novalidate attribute of the <form> element.
The formnovalidate attribute can be used with type="submit".
A form with two submit buttons (with and without validation):
The formtarget Attribute
The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.
The formtarget attribute overrides the target attribute of the <form> element.
The formtarget attribute can be used with type="submit" and type="image".