ARIA: comment 角色
comment 角色在语义上表示对页面上某个内容,或对先前评论的评论/反应。
注意: comment 角色是在 WAI-ARIA 1.3 中提议的(最新 ARIA 草案),目前仍在起草中。
示例
在下面的示例中,我们有一个被评论过的文档部分。被评论的部分使用 <span role="mark"> 标记。
相关的评论使用一个包裹在 <div> 中的 HTML 结构来标记,该 <div> 包含 role="comment"。
html
<p>
The last half of the song is a slow-rising crescendo that peaks at the
<span role="mark" aria-details="thread-1">end of the guitar solo</span>,
before fading away sharply.
</p>
<div role="comment" id="thread-1" data-author="chris">
<h3>Chris said</h3>
<p class="comment-text">I really think this moment could use more cowbell.</p>
<p><time datetime="2019-03-30T19:29">March 30 2019, 19:29</time></p>
</div>
为了将评论与被评论的文本关联起来,我们需要将被评论的文本包裹在一个包含 aria-details 属性的元素中,该属性的值应该是评论的 ID。
多个评论
由于 aria-details 现在可以接受多个 ID,我们可以将多个评论与同一个注释关联起来,如下所示:
html
<p>
The last half of the song is a slow-rising crescendo that peaks at the
<mark aria-details="thread-1 thread-2">end of the guitar solo</mark>, before
fading away sharply.
</p>
<div role="comment" id="thread-1" data-author="chris">
<h3>Chris said</h3>
<p class="comment-text">I really think this moment could use more cowbell.</p>
<p><time datetime="2019-03-30T19:29">March 30 2019, 19:29</time></p>
</div>
<div role="comment" id="thread-2" data-author="chris">
<h3>Marcus said</h3>
<p class="comment-text">
The guitar solo could do with a touch more chorus, and a slightly lower
volume.
</p>
<p><time datetime="2019-03-29T15:35">March 29 2019, 15:35</time></p>
</div>
嵌套评论
可以将评论嵌套在彼此内部,如下所示:
html
<div role="comment" id="thread-1" data-author="chris">
<h3>Chris said</h3>
<p class="comment-text">I really think this moment could use more cowbell.</p>
<p><time datetime="2021-03-30T19:29">March 30 2021, 19:29</time></p>
<div role="comment" data-author="marcus">
<h3>Marcus replied</h3>
<p class="comment-text">
I don't know about that. I think the cowbell could distract from the solo.
</p>
<p><time datetime="2021-03-30T21:02">March 30 2021, 21:02</time></p>
</div>
</div>
可访问性考虑
无。
规范
将成为 WAI-ARIA 1.3 的一部分,该版本仍在起草中。