PageResource.com - Web Development Tutorials

HTML5 Input Tag Attributes

HTML5 introduces several new attributes to the <input> tag. These attributes make it easier to create forms and set automatic validation.

Below is a list of all the new attributes for the <input> tag and their values.

Attribute Value Description
autocomplete on
off
Specifies whether or not the the input field should have autocomplete enabled.
autofocus autofocus Specifies that the input field should have focus on page load (not for type=”hidden”)
form formname Specifies one or more forms the input field belongs to
formaction URL Overrides the form’s action attribute. Must be a valid URL that defines where to send the data when the form is submitted (for type=”submit” and type=”image”)
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Overrides the form’s enctype attribute. Specifies how form-data should be encoded before sending it to the server (for type=”submit” and type=”image”)
formmethod get
post
Overrides the form’s method attribute. Defines the HTTP method for sending data to the action URL (fo type=”submit” and type=”image”)
formnovalidate formnovalidate Overrides the form’s novalidate attribute. If present the input field should not be validated when submitted
formtarget _blank
_self
_parent
_top
framename
Overrides the form’s target attribute. Specifies the target window used when the form is submitted (for type=”submit” and type=”image”)
height pixels
%
Defines the height of an input (for type=”image”)
list datalist-id Refers to a datalist containing predefined options for the input field
max number
date
Specifies the input field’s maximum value. Use together with the “min” attribute to create a range of legal values
min number
date
Specifies the input field’s minimum value. Use together with the “max” attribute to create a range of legal values
multiple multiple If present the user is allowed more than one value
pattern regexp_pattern Specifes a pattern or format for the input field’s value. Example: pattern=”[0-9]” means that the input value must be a number between 0 an 9
placeholder text Specifies a hint to help users fill out the input field
required required Indicates that the input field’s value is required in order to submit the form.
step number Specifies the legal number intervals for the input field
width pixels
%
Specifies the width of an input (for type=”image”)

One Response to “HTML5 Input Tag Attributes”

  1. Fritz schenk Says:

    There is one at least one validation rule missing from this set:
    1.Dependent: this element’s value is dependent on an expression composed of constants and values of other elements; the expression follows javascript syntax.
    This validation rule was used for what I called cross validation.
    2.Setting of the formnovalidte upon the truth of an expression or a regexp_pattern.

    [Reply]

Leave a Reply


Copyright © The Web Design Resource. All rights reserved. | Contact Us | Privacy Policy