在页面部分(哈希)link 上使用 role=button 在语义上是否正确?

Is it semantically correct to use role=button on a page section (hash) link?

我有指向页面中部分的链接。为了提高可访问性,我向这些添加了 role="button" 属性,因为我的理解是这些链接在页面内并且只是转到一个部分。但是我不确定这样做是否合适。

<ul>
  <li><a role="button" href='#section1'>Go to section 1</a></li>
  <li><a role="button" href='#section2'>Go to section 2</a></li>
</ul>

<div style="height:15rem"></div>

<h2 id='section1'>Section 1</h2>

<div style="height:15rem"></div>

<h2 id='section2'>Section 2</h2>

没有

您有链接,这些链接起到链接的作用。他们链接到同一页面的另一部分并不能使他们成为按钮。

WAI-ARIA Authoring Practices 1.1

A button is a widget that enables users to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.

你正在做 none 这些事情。

它还说:

The types of actions performed by buttons are distinctly different from the function of a link (see link pattern). It is important that both the appearance and role of a widget match the function it provides. Nevertheless, elements occasionally have the visual style of a link but perform the action of a button. In such cases, giving the element role button helps assistive technology users understand the function of the element. However, a better solution is to adjust the visual design so it matches the function and ARIA role.

…这突出了链接是另一回事。