HTML5 Guidelines for Web Developers

(coco) #1
3.2 Useful Attributes for Forms 45

3.2.4 Even More Attributes for the “input” Element


The input element has not only been enhanced with new types (section 3.1, New
Input Types), but also with new attributes that enable easier handling of forms
(see Table 3.2).


Table 3.2 New Attributes for the “input” Element


Type Description Attribute

liststring Refers to the ID of a datalist element with
suggestions (see section 3.3.3, Lists of op-
tions with “datalist”)

list

numeric/date Minimum value of numeric fields and date
fields

min

numeric/date Maximum value of numeric fields and date
fields

max

numeric Step size of numeric fields and date fields step

boolean Multiple selection possible multiple
enumerated
(on/off/default)

Automatically inserts saved data into form
fields

autocomplete

string Regular expression for validating the value pattern

We will come across the list attribute again in section 3.3.3, Lists of Options
with “datalist”. It refers to the datalist element, which offers possible entries as
suggestions.


min, max, and step are not only suitable for numeric fields, but these attributes
can also be used for entering the date and time:



min=0 max=1 step=0.1>


min=2010-08-01 max=2010-11-11 step=7>


min=14:30 max=19:30 step=3600>

In browsers that support the input type number, the first input element (id=minMax)
is increased each time by a value of 0.1. This works by clicking the arrow keys at
the end of the text field or by pressing the arrow keys on the keyboard. The ele-

Free download pdf