大网数据广告活动
Web 标准与前端开发

ARIA: mark role

· 52CE 我爱测

The `mark` role denotes content which is marked or highlighted for reference or notation purposes, due to the content's relevance in the enclosing context.

The mark role denotes content which is marked or highlighted for reference or notation purposes, due to the content's relevance in the enclosing context.

Description

The mark role semantically denotes HTML elements containing text that is marked/highlighted for reference purposes. This is semantically equivalent to the HTML mark element. If possible, you should use this element instead.

Example uses for mark are the exact same as the <mark> element. They include highlighting text in a quotation which is of special interest but is not marked in the original source material, comparable to using a highlighter pen to mark passages of a print article and indicating portions of the content that are relevant to the user's current activity, such as highlighting text matches found by a search feature.

Don't use mark for purely decorative styling such as syntax highlighting.

The mark element should not be given an accessible name; both aria-label and aria-labelledby attributes are prohibited on mark.

Examples

In the following example we have a document section that has been commented. The commented section is marked up using <span role="mark">.

<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="2022-03-30T19:29">March 30 2022, 19:29</time></p>
</div>

The related comment is marked up using an HTML structure wrapped with a div containing role="comment".

To associate the comment with the text being commented, we need to wrap the commented text with an element containing the aria-details attribute, the value of which should be the ID of the comment.

Best practices

Prefer HTML

Using the mark element will automatically communicate a node has a role of mark. If at all possible, prefer using it instead.

Specifications

Will be part of WAI-ARIA 1.3, which is still being drafted.

See also

  • HTML mark element

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。