HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 17. FORMS AND INPUTS 181


Required Answer:autofocus=


Theautofocus=attribute causes the focus to begin on a certain element.
Normally it would be used with an<input ...>element. This causes the
cursor to rest inside that field when the page is first loaded.


The value of autofocus does not matter, so it can be left off. In that case,
the equals sign can also be left off.


When the user pressed the tabkey, the tabindex= attribute tells the
browser where to send the cursor next. After the highest-numbered field,
tabbing returns to the lowest-numbered field. If tabindex is not specified,
the browser normally sends the cursor to the next input field it can find in
the HTML.


Exam Question 315(p.355):What HTML attribute= is used to specify
the order in which fields are reached by tabbing?
Required Answer:tabindex=


Normally a user provides bits of information as they fill out a form. At the
conclusion of providing each bit of information, the user can press the TAB
key to move to the next field.


The normal sequence of fields is exactly the same as the order in which the
appear in the HTML of the webpage.


Sometimes we want that order to be different.


We can control tab order using thetabindexattribute.


<input ... tabindex=1 ...>


When you press the TAB key, your browser will move to the input field with
the next higher tabindex. After it reaches the highest tabindex, it will start
over with the lowest one.


If several fields have the same tabindex, they go in the order that they
appear in the HTML.


http://www.w3schools.com/tags/att_global_tabindex.asphas more.

Free download pdf