jump to navigation

NOTE: The spam filter is being unusually aggressive. If you comment does not immediately appear, it has simply been placed in moderation and I will approve it as quickly as possible. Thank you for your patience.

"Murphy was an optimist!"

Always more to learn January 5, 2009 2:15 pm

Posted by Doug McCaughan in : ColdFusion, HTML, JavaScript, PHP, Programming, Technology
, trackback

No matter how long you do something, there is always more to learn. You’d think that since I’ve been doing HTML coding since around 1993, I’d pretty much know every in and out and every little tag and peculiarity regarding HTML. Not so. See, we form habits. We get into patterns. Specs change but we retain earlier hacks and assumptions. Today I learned an absurdly simple thing. Maybe I knew this and forgot. I rarely use tab orders on my forms. Most of the forms I create are very top down so the natural tab order is sufficient. In computing, counting starts at zero. But in HTML tab order, zero means exclude that form element from the tab order.

To exclude an element from the tab order, set the value of tabindex to 0. [Source, Webcheatsheet.com, How to Control Tab Order in HTML]

Because of my computer science studies, programming in PHP, JavaScript, C and so on, my inclination is to always begin with zero. Of course, my favorite web application language is ColdFusion and it always starts at one. I can only assume the Allaire brothers were originally targeting non-programmers.

HTML is about to become HTML 5. Funny enough I just traded my HTML 3.2 book at McCay’s a few weeks ago. Maybe I should have kept it and re-read it.

Update Jan 12, 2009: Ian Tempest noted in the comments that zero does not exclude an element but rather moves it to the end of the tab order. From the W3C HTML 4.01 specification:

Those elements that do not support the tabindex attribute or support it and assign it a value of “0? are navigated next. These elements are navigated in the order they appear in the character stream. [Source, W3C, 17.11.1 Tabbing navigation]

Comments after advertisement

Comments»

1. Ian Tempest - January 12, 2009

Hello Doug,

Zero tabindex behaviour is slightly different to how you describe, though this could be an issue of semantics. The ‘zero elements’ will be navigated after the positive tabindex elements. To exclude an element from the taborder (i.e. to make it ‘untabbable’) it should be assigned a negative tabindex.

http://www.w3.org/TR/html401/interact/forms.html#h-17.11.1

2. Doug McCaughan - January 12, 2009

Not an issue of semantics at all. Normally I look to the W3C for this kind of information. This time I took the info from Webcheatsheet.com

Reading at the W3C link you made above we have:

This value must be a number between 0 and 32767.

Negative numbers are not allowed. We also have:

  1. Those elements that support the tabindex attribute and assign a positive value to it are navigated first. Navigation proceeds from the element with the lowest tabindex value to the element with the highest value. Values need not be sequential nor must they begin with any particular value. Elements that have identical tabindex values should be navigated in the order they appear in the character stream.
  2. Those elements that do not support the tabindex attribute or support it and assign it a value of “0” are navigated next. These elements are navigated in the order they appear in the character stream.

So it would seem that aside from “disabled” no number excludes an element from the tab order. You are correct with zero. Zero moves the element to the last of the tab order. Thanks for pointing this out!


trackback