tabindex属性_tabindex(HTML属性)

tabindex属性

描述 (Description)

The tabindex is used to define a sequence that users follow when they use the Tab key to navigate through a page. By default, the natural tabbing order will match the source order in the markup. In certain circumstances it may be necessary to override the default tabbing order, but it’s strongly recommended that you craft a page in a logical flow and let the browser work through it in the default order—an approach that negates the need for the tabindex attribute.

tabindex用于定义用户使用Tab键浏览页面时遵循的顺序。 默认情况下,自然制表顺序将与标记中的源顺序匹配。 在某些情况下,可能有必要覆盖默认的制表顺序,但是强烈建议您以逻辑流程制作页面,并让浏览器以默认顺序浏览该页面-这种方法不需要使用tabindex属性。

A tabindex can start at 0 and increment in any value. As such, the sequence 1, 2, 3, 4, 5 would be fine, as would 10, 20, 30, 40, 50. If you need to introduce a tabindex, it’s advisable to use a sequence that contains intervals (like the second example provided), as this will give you the opportunity to inject other controls later if need be (for example, 10, 15, 20) without having to reindex all the tabindex values on the page. Should a given tabindex value be applied to more than one element (e.g. all links in one section given a tabindex of “1”, and sidebar links given a tabindex of “2”), the tabbing order of those affected elements will be as per the source markup order. Many people will choose to use this approach rather than a sequence with a defined interval, such as 5, 10, 15, because it allows for additional links or form controls to be added without the headache of re-numbering. If a tabindex of “-1” is used, the element it’s applied to will no longer be keyboard focusable.

tabindex可以从0开始,可以任意增加。 因此,顺序1、2、3、4、5和10、20、30、40、50都可以。如果需要引入tabindex ,建议使用包含间隔的序列(例如提供第二个示例),因为这将使您有机会在以后需要时(例如10、15、20)注入其他控件,而不必重新索引页面上的所有tabindex值。 如果将给定的tabindex值应用于一个以上的元素(例如,一节中的所有链接的tabindex为“ 1”,侧栏链接的tabindex为“ 2”),则受影响元素的制表顺序将按照源标记顺序。 许多人会选择使用此方法,而不是使用具有定义间隔的序列,例如5、10、15,因为它允许添加其他链接或表单控件,而无需重新编号。 如果使用tabindex为“ -1”,则应用于该元素的元素将不再是键盘可聚焦的。

If a tabindex is set anywhere on a page—even if it’s the hundredth link or the fiftieth form control—the tab order will start at the element with the lowest tabindex value, and work through the increments. Only then will the tab order take in the remaining elements for which no tabindex has been set. As such, great care must be taken to ensure that adding a tabindex doesn’t harm the usability of the page as a whole.

如果将tabindex设置在页面上的任何位置(即使是第百个链接或第五十个窗体控件),则制表符顺序将从具有最低tabindex值的元素开始,并逐步进行。 只有这样,制表符顺序才会接受未设置tabindex的其余元素。 因此,必须tabindex小心,以确保添加tabindex不会损害整个页面的可用性。

If the disabled attribute is set on an element which has a tabindex, that tabindex will be ignored.

如果将禁用属性设置在具有tabindex的元素上,则该tabindex将被忽略。

(Example)

The tabindex is set to "3" for the link below:

以下链接的tabindex设置为"3"

<p>You can try our <a href="cakes.html" tabindex="3">lovely
     range of cakes</a>.</p>

(Value)

This attribute can take any numeric value.

此属性可以采用任何数值。

翻译自: https://www.sitepoint.com/tabindex-html-attribute/

tabindex属性

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值