在html中,如果要使任意元素成为键盘焦点,可以向它们添加属性tabindex="0"
(例如http://snook.ca/archives/accessibility_and_usability/elements_focusable_with_tabindex)。
HTML5规范通过使任何元素的tabindex
属性合法来批准这一点:
http://dev.w3.org/html5/spec-author-view/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
http://dev.w3.org/html5/spec-author-view/index.html#attributes-1
然而,据我所知,这似乎不适用于chrome和safari中的<label>
元素,也不适用于firefox中的<label>
元素,直到3.6(在那里,一旦用户到达<label>
,它就会阻止用户进一步在页面中切换)。
http://jsfiddle.net/TaCC3/
有什么方法可以使的键盘在safari/chrome和/或旧版本的firefox中成为焦点吗?
最佳答案
我认为标签标签的全部目的是将焦点放在其他元素上,而不是放在它本身。