Prev | Current Page 403 | Next

Craig Grannell

"The Essential Guide to CSS and HTML Web Design"

Because the tabindex values needn??™t be
sequential, it??™s advisable to set them in increments of ten, enabling you to insert others
later, without having to rework every value on the page. With that in mind, you could
set tabindex="10" on the realname field, tabindex="20" on the email field, and
tabindex="30" on the phone field (these field names are based on their id/name values
from the previous example). Assuming no other tabindex attributes with lower values are
elsewhere on the page, the realname field becomes the first element highlighted when the
Tab key is pressed, and then the cycle continues (in order) with the email and phone fields.
Note that whenever using tabindex, you run the risk of hijacking the mouse cursor, meaning
that instead of the Tab key moving the user from the first form field to the second, it
might end up highlighting something totally different, elsewhere on the page. What??™s logical
to some people in terms of tab order may not be to others, so always ensure you test
your websites thoroughly, responding to feedback. Generally, it makes sense to use the
value only for form fields, and then with plenty of care.
The reason for starting with 10 rather than 1 is because if you ignore the last digit, the
tabindex values become standard integers, starting with 1. In other words, remove
the final digits from 10, 20, and 30, and you end up with 1, 2, and 3. This makes it easier
to keep track of the tabindex order.


Pages:
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415