HTML and CSS Reference
In-Depth Information
HTML5 Forms
There are a number of additions in HTML5 to forms, and the input fields they contain. Form
elements such as input fields and select boxes had not really changed since the early versions
of HTML. Not only does HTML5 introduce a new set of input types, it includes a large set
of attributes for customising form inputs, along with native validation of form fields.
New Input Types
If you look at the input type of the field named “requiredBy” you will notice that its type is
set to date :
<input type="date" required="required"name="requiredBy"/>
//
It is also valid, and possibly preferable, to write this as
<input type="date" required name="requiredBy"/>
HTML5 does not require all attributes to have values. These attributes are referred
to as Boolean attributes, since their presence indicates true , and their absence in-
dicates false .
It is arguably preferable to omit the value because it avoids the possibility of be-
lieving the following is valid:
required="false"
It is the expectation of the HTML5 specification that the browser will provide the user some
way to choose a date when they click on such a field, although the exact mechanism is left
up to browser vendors.
Some browsers do not currently support the date input type, and in those cases it acts just
like a text input type.
When browsers choose to implement one of the new input types they can decide on the best
way to implement it based on the specifics of the device they are running on. For instance,
the date input type on the iPad displays the following calendar:
Search WWH ::




Custom Search