HTML5 Form Attributes

HTML5 brings us new form attributes that you can use reduce the dependency of JavaScript to manage your input form elements. For example, some of the new attributes allow you to set a minimum or maximum value for an input element, or
set a maximum length which can limit the input of a string value. As HTML5 is being developed, one of the considerations has been making forms on the web easier to use with built-in
features without the need for extra JavaScript. The new HTML5 form attributes, as of this writing, is not supported by all of the major browsers. Chrome, Opera, Firefox, and Safari have the most support. Each item below is tested for
support in the current browser. In the items below, green indicates that your current browser should support the attribute while red indicates that it
does not. Please note that the HTML5 specification is still being developed, so this information can change. On the right side of this text, you will notice that this page has detected your browser version.

Form Attributes

Description

autocomplete

Specifies is a field should enable the autocomplete feature.

autofocus

Focuses the input on the element when the page is loaded.

form

Specifies one or more forms to which the input element belongs.

formaction

Overrides the action attribute on the form element.

formenctype

Overides the enctype attribute on the form element.

formmethod

Overrides the method attribute on the form element.

formnovalidate

Overrides the novalidate attribute on the form element.

formtarget

Overrides the target attribute on the form element.

heigth

Sets the height of an input element of type "image".

list

The list attribute refers to a datalist element that contains pre-defined options for an input element.

max

The max attribute specify the maximum value for an input element.

maxlength

The maxlength attribute limits the number of characters that an input or textarea can accept.

multiple

Allows file inputs to accept more than one file for upload.

min

The min attribute specify the minimum value for an input element.

novalidate

Disables the form submission validation when specified on a form element.

pattern

Validates the value of an element value against a regular expression.

placeholder

Gives the user a hint about what type of data they should enter.

required

A boolean attribute that means the element is required.

step

Value specified that increments the value for an input with the type equal to "number".

width

Sets the width of an input element of type "image"

Autocomplete

The autocomplete attribute specifies whether a form or input field should have autocomplete on or off. If the autocomplete attribute is set to "on", the browser automatically
complete values based on values that the user has entered before. You may need to activate the autocomplete function in your browser for this attribute to work properly.

Required

The required attribute is a boolean attribute. If specified, an input field must be filled out before submitting the form.

UserName:<input type="text" name="username" required>

Step

The step attribute specifies the number interval for an <input> element.

Points:<input type="number" step="2">

Please help us spread the word by socializing it today!

Did you find something wrong with the information on this page? Please take a moment to report it to us
so that we can continue to improve the quality of the information on this site. Click here to
report an issue with this page.