HTML5 Guidelines for Web Developers

(coco) #1
3.2 Useful Attributes for Forms 43

This test works even better with BlackBerry, the operating system of the popular
line of smartphones produced by the Canadian manufacturer Research in Mo-
tion (RIM). As you can see in Figure 3.4, the BlackBerry supports both tel and
number plus date types, and the latter in particular are represented in very at-
tractive graphics. Under the hood we find WebKit at work: The software was ex-
panded to include these functions.


Figure 3.4 The new input types on a BlackBerry smartphone (BlackBerry 9800 simulator)


3.2 Useful Attributes for Forms


Apart from new elements and many new types for the input element, HTML5
also offers several new attributes for form elements.


3.2.1 Focusing with “autofocus”..........................................................


Years ago, Google surprised many users with a simple trick that made searching
much more convenient: When the page was loaded, the cursor was automati-
cally positioned in the search field. The user was able to enter the search term
directly without having to first activate the input box by clicking with the mouse.
Previously, this was done with a short snippet of JavaScript; in HTML5 you can
now do it with the autofocus attribute:



As with all boolean attributes, you can write this attribute as autofocus="autofocus"
(see Chapter 2, section 2.7.2, The “time” Element). The specification states that
only one element in a web page can contain the autofocus attribute.

Free download pdf