Frage

Is there accessibility or semantic purpose to include a tabindex attribute on an input[type="reset"]? Or should this be avoided so forms aren't accidentally and often reset?

War es hilfreich?

Lösung

If you have a reset button, then setting tabIndex=-1 reduces the risks caused by the button by removing it from the tabbing order. Any negative value for the tabIndex attribute means that browsers do not “allow the element to be reached using sequential focus navigation”. (This is not defined in HTML 4, which does not allow negative values, but it is common browser behavior and being standardized in HTML5.) This implies that a user won’t accidentally destroy his input data by tabbing to the reset button and pressing Enter.

On the other hand, this would be an accessibility problem in the very rare cases where the reset button would actually be needed. A user without a mouse, or with a motoric disability, would find it difficult or impossible to reset the form. It would also be a usability problem to a user who uses keyboard navigation and controls for convenience: he would notice that the reset button is skipped in tabbing and might not understand what to do.

Similar considerations apply to other values, which could change the position of the element in the tabbing order. Generally, making the tabbing order differ from the apparent order of the elements tends to confuse. But if the reset button precedes the submit button in markup, putting it later in the tabbing order would probably reduce the risk that the user destroys his data instead of submitting it.

The key issue with the reset button, in usability and accessibility sense and otherwise, is that it should not be used, except in very rare cases (in which it should normally appear first in the form, both in markup and in tabbing order). As Jakob Nielsen, the usability guru, wrote long ago: “The Web would be a happier place if virtually all Reset buttons were removed. This button almost never helps users, but often hurts them.”

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top