HTML5 New Form Attributes
HTML5 has several new attributes for <form> and <input>.
New attributes for <form>:
New attributes for <input>:
- autocomplete
- autofocus
- form
- formaction
- formenctype
- formmethod
- formnovalidate
- formtarget
- height and width
- list
- min and max
- multiple
- pattern (regexp)
- placeholder
- required
- step
<form> / <input> 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 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.
Note: The autocomplete attribute works with <form> and the
following <input> types: text, search, url, tel, email, password, datepickers, range, and color.
Tip: In some browsers you may need to activate the autocomplete function for this to work.
<form> novalidate Attribute
The novalidate attribute is a boolean attribute.
When present, it specifies that the form-data (input) should not be validated when submitted.
<input> autofocus Attribute
The autofocus attribute is a boolean attribute.
When present, it specifies that an <input> element should automatically get focus when the page loads.
<input> 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.
<input> 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.
Note: The formaction attribute is used with type="submit" and type="image".
<input> formenctype Attribute
The formenctype attribute specifies how the form-data should be encoded when submitting it to the
server (only for forms with method="post")
The formenctype attribute overrides the enctype attribute of the <form> element.
Note: The formenctype attribute is used with type="submit" and type="image".
<input> 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.
Note: The formmethod attribute can be used with type="submit" and type="image".
<input> formnovalidate Attribute
The novalidate attribute is a boolean attribute.
When present, it specifies that the <input> element should not be validated when submitted.
The formnovalidate attribute overrides the novalidate attribute of the <form> element.
Note: The formnovalidate attribute can be used with type="submit".
<input> 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.
Note: The formtarget attribute can be used with type="submit" and type="image".
<input> height and width Attributes
The height and width attributes specify the height and width of an <input> element.
Note: The height and width attributes are only used with <input type="image">.
Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the
image is reserved when the page is loaded. However, without these attributes,
the browser does not know the size of the image, and cannot reserve the
appropriate space to it. The effect will be that the page layout will change
during loading (while the images load).
<input> list Attribute
The list attribute refers to a <datalist> element that contains pre-defined options for an <input> element.
<input> min and max Attributes
The min and max attributes specify the minimum and maximum value for an <input> element.
Note: The min and max attributes works with the
following input types: number, range, date, datetime, datetime-local,
month, time and week.
<input> multiple Attribute
The multiple attribute is a boolean attribute.
When present, it specifies that the user is allowed to enter more than one value in the <input> element.
Note: The multiple attribute works with the following input types: email, and file.
<input> pattern Attribute
The pattern attribute specifies a regular expression that the <input> element's value is checked against.
Note: The pattern attribute works with the following input types: text, search, url, tel, email, and password.
Tip: Use the global
title attribute to describe the pattern to help the user.
Tip: Learn more about
regular expressions in our JavaScript tutorial.
<input> placeholder Attribute
The placeholder attribute specifies a short hint that describes the
expected value of an input field (e.g. a sample value or a short
description of the expected format).
The short hint is displayed in the input field before the user enters a
value.
Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.
<input> required Attribute
The required attribute is a boolean attribute.
When present, it specifies that an input field must be filled out before submitting the form.
Note: The required attribute works with the following input
types: text, search, url, tel, email, password, date pickers, number,
checkbox, radio, and file.
<input> step Attribute
The step attribute specifies the legal number intervals for an <input> element.
Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.
Tip: The step attribute can be used together with the
max and min attributes to create a range of legal values.
Note: The step attribute works with the following
input types: number, range, date, datetime, datetime-local, month, time and week.
HTML5 <input> Tag
| Tag |
Description |
| <form> |
Defines an HTML form for user input |
| <input> |
Defines an input control |