简体   繁体   English

使屏幕阅读器以不同的方式阅读章节

[英]Make screen reader read sections differently

I have a nested, 3-level navigation that looks like this in HTML: 我有一个嵌套的三级导航,在HTML中如下所示:

<ul class="level-0 top">
  <li>
    <a>Link</a>
    <ul class="level-1 column">
      <li>
        <a>Header</a>
        <ul class="level-3 row">
          <li>
            <a>Link</a>
          </li>
          <li>
            <a>Link</a>
          </li>
          <li>
            <a>Link</a>
          </li>
        </ul>
  <!-- more 1st, 2nd, and 3rd levels that look like the above -->
</ul>

It's styled as a megamenu: 它的样式为megamenu:

                             *Link1* Link2 Link 3
 ________________________________________________
| Header |  Header  |  Header  |  Random Content |
| Link   |  Link    |  Link    |                 |
| Link   |  Link    |  Link    |                 |
| Link   |  Link    |          |                 |
|        |  Link    |  Header  |                 |
| Header |  Link    |  Link    |                 |
| Link   |          |  Link    |                 |
| Link   |  Header  |  Link    |                 |
|        |  Link    |  Link    |                 |
|        |  Link    |          |                 |
|        |  Link    |          |                 |
'------------------------------------------------'

The first level is the links up top, which opens a mega menu drop down. 第一级是顶部的链接,它打开一个大型菜单下拉菜单。 The second level would be the "columns" in the mega menu. 第二个级别是超级菜单中的“列”。 The third level would be the "rows" inside each column, each containing a list of links. 第三层是每一列内的“行”,每行包含一个链接列表。 A good way to imagine the layout is to think of the Pinterest "masonry" arrangement. 设想布局的一种好方法是考虑Pinterest的“砌体”布置。

Now when navigating a screen reader into the menu (the second level), naturally, it would read "region with two items" (or some variant of this blurb depending on your reader) because it sees two lists in each column. 现在,当将屏幕阅读器导航到菜单(第二级)时,它自然会显示“有两个项目的区域”(或此blur的某种变体,具体取决于您的阅读器),因为它在每一列中看到两个列表。 Then it would read each third-level list, get out of the list, get out of the first column, and repeat for the other columns. 然后它将读取每个第三级列表,从列表中退出,从第一列中退出,然后对其他列重复。

This makes logical sense when reading the HTML and to a screen reader. 在读取HTML和屏幕阅读器时,这是合乎逻辑的。 You descend a level, read the summary of items, reach each item, repeat. 您下降一个级别,阅读项目摘要,到达每个项目,然后重复。

However... 然而...

                             *Link1* Link2 Link 3
 ________________________________________________
| Header    Header     Header  |  Random Content |
| Link      Link       Link    |                 |
| Link      Link       Link    |                 |
| Link      Link               |                 |
|           Link       Header  |                 |
| Header    Link       Link    |                 |
| Link                 Link    |                 |
| Link      Header     Link    |                 |
|           Link       Link    |                 |
|           Link               |                 |
|           Link               |                 |
'------------------------------------------------'

The menu is designed in a way that the first 3 columns don't look like columns . 菜单的设计方式是前3列看起来并不像列 Instead, the first to third columns is seen as one big region with 6 lists of links (imagine the first three columns having the same background, while Random Content has a different-colored background). 相反,第一到第三列被视为一个包含6个链接列表的大区域(想象前三列具有相同的背景,而随机内容具有不同颜色的背景)。

Is there a way to tell a screen reader to read the first to third columns as "one region with 6 items", even when the HTML is defined in columns and rows? 即使在列和行中定义了HTML,是否有一种方法可以告诉屏幕阅读器将第一至第三列读取为“一个区域包含6个项目”? Or is it already reading it in a compliant manner? 还是已经以符合要求的方式阅读了?

You could force the screen reader to read it the way you want but I don't think it's necessary for your example. 可以强制屏幕阅读器以您想要的方式阅读它,但我认为您的示例没有必要。 Just because you style it to look like one group with six groupings doesn't mean it has to be read that way. 仅仅因为您将其样式设置为看起来像具有六个分组的一组,并不意味着就必须以这种方式阅读。 There isn't any additional meaning with your visuals. 视觉效果没有任何其他含义。

But if you really want to do it, here's a simple example: 但是,如果您确实想要这样做,那么这里有一个简单的示例:

<ul>
  <li>a</li>
  <li>b</li>
</ul>
<ul>
  <li>c</li>
  <li>d</li>
  <li>e</li>
</ul>

This is read as two separate lists, one with two items and another with three items. 这被视为两个单独的列表,一个包含两个项目,另一个包含三个项目。 If you wanted them to be read as one list with five items (essentially what you're asking for), you'd have to use roles to do so. 如果您希望将它们作为一个包含五个项目的列表(基本上是您要的内容)阅读,则必须使用角色。

<div role="list">
  <ul role="presentation">
    <li role="listitem">a</li>
    <li role="listitem">b</li>
  </ul>
  <ul role="presentation">
    <li role="listitem">c</li>
    <li role="listitem">d</li>
    <li role="listitem">e</li>
  </ul>
</div>

You'd need the <div> as a container for the list and you have to remove the "list-ness" of the <ul> by specifying role="presentation" . 您需要将<div>作为列表的容器,并且必须通过指定role="presentation"来删除<ul>的“ list-ness role="presentation" However, because role="presentation" on a parent element will propagate down to "owned" elements (the <li> elements), you need to reinstate the "list item-ness" of the <li> elements by adding role="listitem" . 然而,由于role="presentation"父元素将向下传播到“拥有”元素(在<LI>元素),您需要重新恢复的“列表项性” <li>通过添加元素role="listitem"

See https://www.w3.org/TR/wai-aria/#presentation 参见https://www.w3.org/TR/wai-aria/#presentation

When an explicit or inherited role of presentation is applied to an element with the implicit semantic of a WAI-ARIA role that has required owned elements, in addition to the element with the explicit role of presentation, the user agent MUST apply an inherited role of presentation to any owned elements that do not have an explicit role defined. 当呈现的显式或继承角色应用于具有WAI-ARIA角色的隐式语义的元素且该元素具有必需的元素时,除了具有呈现的显式角色的元素外,用户代理还必须应用的继承角色向所有未定义明确角色的拥有元素进行演示。

You now have one list with five items. 您现在有了一个包含五个项目的列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使屏幕阅读器将“ 16”读为“十六” - Make screen reader read “16” as “sixteen” ARIA屏幕阅读器-如何读取角色名称? - ARIA Screen Reader - how to make a role name read? 让屏幕阅读器在Angular app中读取新的页面标题 - Make screen reader read new page title in Angular app WCAG - 如何让屏幕阅读器自动阅读所有页面? - WCAG - How to make the screen reader read all the page automatically? 使屏幕阅读器忽略部分,但阅读其重点内容 - Make screen reader ignore a section but read its focusable content 如何使NVDA屏幕阅读器阅读aria标签? - How to make NVDA screen reader read the aria-label? 使屏幕阅读器阅读跨度文本的正确方法是什么 - What is the correct way to make screen reader read span text 如何使JAWS屏幕阅读器阅读标题文件,逐字逐句而不是句子阅读? - how to make JAWS screen reader to read the title document to read separately letter by letter instead of sentence? 如何制作屏幕阅读器选项 - How to make a screen reader option 如果初始焦点设置为另一个元素,如何让屏幕阅读器在安装时读取组件中的标题? - How to make screen reader read a heading in a component on mount if initial focus is set to another element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM