哪些HTML元素即使使用tabindex也不可tabbable? [英] What HTML elements are not tabbable even with tabindex?

查看:254
本文介绍了哪些HTML元素即使使用tabindex也不可tabbable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有HTML(HTML5)元素的不是 tabbable列表,即使指定了tabindex? (通过tabbable,我的意思是说,他们可以通过反复按tab键来获得焦点。)

我们知道有些元素是默认可以设置的,如输入 textarea 。我们也知道,如果明确地指定了一个tabindex,就会有一些元素只能是tabbable,比如 div span 元素。

根据W3School的说法,在HTML5中,tabindex属性可用于任何HTML元素。但是,即使有tabindex,也肯定有一些元素是不可tabbable的。例如, param 元素是可以放置的,或者是元素元素是没有意义的。我也不认为选项元素是可能的,但是我不确定。我甚至不太确定像 map 这样的东西,它可以包含可放大的元素,但通常不会自己放置。



有人可以给我所有的元素,即使他们有一个tabindex从来没有得到的焦点列表?

解决方案

由于没有一个还没有提出任何明确的名单,我做了一些相当新的Chrome版本的测试,并提出了下面的元素列表:


  • < base>

  • < basefont> / code>

  • < embed>

  • < head>

  • < link> > < meta>

  • < object>
  • < param>

  • < source> ;

  • &l t; track>



不幸的是,由于我只花了几个小时试图写这个列表,它有一些注意事项:


  1. 未在除Chrome之外的任何浏览器上测试过
  2. 跳过大多数我认为可能是可以放置的元素(因为他们会有正常的显示内容)

  3. 我没有尝试设置其中的任何显示(除了

我最惊讶的是下面的元素

$ b

  • < audio> and < video> (因为< embed> < object>
  • < br> < wbr>
  • < col> < colgroup> li>
  • < frame> < frameset> (尽管它们是更多的是一种特殊情况,因为它们在HTML中不是技术上有效的元素)
  • < html> (几乎没有区别在这个和< body> 之间从tab键的角度来看)
  • < optgroup> (尽管标签对它们没有任何可见的指示 - 即选择框不打开) / ul>

    Does anyone have a list of the HTML (HTML5) elements that are not tabbable, even if a tabindex is specified? (By tabbable, I mean that they can receive the focus through repeatedly pressing the "tab" key.)

    We know that there are those elements which are tabbable by default, such as input or textarea. We also know that there are some elements which are only tabbable if a tabindex is explicitly specified, such as div and span elements.

    According to W3Schools, "In HTML5, the tabindex attribute can be used on any HTML element". However, there are surely some elements which are not tabbable even if they have a tabindex. For example, it makes no sense for the param element to be tabbable, or the head element. I also don't really think it's possible for the option element to be tabbable, but I'm not sure about that. And I'm even less sure about things like map which can contain tabbable elements but are not usually tabbable themselves.

    Can someone give me a list of all the elements that can never receive focus even if they have a tabindex?

    解决方案

    Since no one has yet come up with any kind of definitive list, I did some testing on a fairly recent version of Chrome and came up with the following list of elements which are not tabbable at all:

    • <base>
    • <basefont>
    • <embed>
    • <head>
    • <link>
    • <meta>
    • <object>
    • <param>
    • <source>
    • <style>
    • <title>
    • <track>

    Unfortunately, since I only spent a couple of hours trying to write this list, it has a few caveats:

    1. Not tested on any browser other than Chrome
    2. I skipped over most of the elements that I thought likely to be tabbable (as they would have normal displayed content)
    3. I have not tried setting any of these to be displayed (apart from <title> as in my comments)

    I was most surprised that the following elements are tabbable:

    • <audio> and <video> (surprised because <embed> and <object> are not)
    • <br> and <wbr>
    • <col> and <colgroup>
    • <frame> and <frameset> (although they are more of a special case as they are not technically valid elements in HTML anyway)
    • <html> (there is almost no difference between this and <body> from a tabbing perspective)
    • <optgroup> and <option> (although tabbing to them does not give any visual indication - i.e. the select box does not open)

    这篇关于哪些HTML元素即使使用tabindex也不可tabbable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆