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

ARIA: math role

· 52CE 我爱测

The `math` role indicates that the content represents a mathematical expression.

The math role indicates that the content represents a mathematical expression.

Description

Content with the role math is intended to be marked up in an accessible format such as MathML, or with another type of textual representation, which can be converted to an accessible format by the browser or a polyfill library.

Unfortunately, browser support for MathML is not universal. While using an image of a mathematical expression is not optimal, if you do use image, use the math role. Make sure any images of math are labeled by an alt attribute that describes the mathematical expression as it would be spoken.

If the math element has only presentational children and the accessible name is intended to convey the mathematical expression, use aria-label to provide a string that represents the expression. If the math element contains navigable content that conveys the mathematical expression and a visible label for the expression is present, use aria-labelledby. Otherwise, use aria-label to name the expression, e.g., aria-label="Pythagorean Theorem".

Examples

If you use image or non-semantic HTML to create an equation, use the math role.

<div role="math" aria-label="a^{2} + b^{2} = c^{2}"> a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup> </div>

The above pythagorean theorem is written accessibly as:

<div role="math" aria-label="a^{2} + b^{2} = c^{2}">
  a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>
</div>

Had an image been used, the alt attribute would be used along with the math role:

<img src="pythagorean_theorem.gif" alt="a^{2} + b^{2} = c^{2}" role="math" />

Specifications

See also

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

资料来源与适用范围

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

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

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