HTML and CSS Reference
In-Depth Information
Currently browsers aren't this helpful, but because this type is
now unambiguous and machine readable/understandable, the
browser knows what the intention of the author is and can con-
ceivably offer more contextually-relevant UI. For example, the
experimental Firefox Contacts add-on
http://mozillalabs.com/
blog/2010/03/contacts-in-the-browser
collects contacts from
various sources, which it uses to offer addresses when a user
comes across an
<input type=email>
. Through the W3C draft
Contacts API
(
http://dev.w3.org/2009/dap/contacts/
), it also
exposes this contact information to website scripts.
The URL input type
<input type=url>
causes the browser to ensure that the value
entered in the field is a correct URL. A browser may offer
assistance to the user—for example, Opera automatically pre-
pends “http://” to URLs that don't have a protocol (that is, the
user didn't type in http:// or ftp:// or whatever). A URL need
not be a web URL; the page could, for example, be a web-
based HTML editor in which the user may wish to use the
tel:
pseudo-protocol.
The date input type
The option
<input type=date>
is one of my favourites. We've all
seen web pages that require the user to enter a date for a flight,
concert ticket, and the like. Because dates are tricky to enter
(is the format DD-MM-YYYY or MM-DD-YYYY or YYYY-MM-DD?),
developers code JavaScript date picker widgets that vary wildly
in appearance, usability, and accessibility between sites.
Using
<input type=date>
solves this problem by providing a
native datepicker widget that's rendered directly by the browser.
Opera, for example, pops up a calendar widget (
Figure 3.3
).
On the BlackBerry browser in BlackBerry Device Software ver-
sion 5.0, the date input control used to implement the date input
field is the same Java component used within the native Black-
Berry calendar app (although it isn't integrated with the calendar
app). See
Figure 3.4
.