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

ARIA: graphics-object role

· 52CE 我爱测

The `graphics-object` role identifies a section of a `graphics-document` that represents a distinct object or sub-component with semantic meaning.

The graphics-object role identifies a section of a graphics-document that represents a distinct object or sub-component with semantic meaning.

[!NOTE] The graphics-object role is defined in the WAI-ARIA Graphics Module specification. It's not part of the core WAI-ARIA specification.

Description

The graphics-object role identifies a distinct part of a larger graphic, such as a region on a map, a bar in a chart, or a node in a diagram. A graphics-object may itself contain nested sub-components. Unlike a graphics-document, it does not need to be self-contained and does not introduce a separate navigation context.

Associated WAI-ARIA roles, states, and properties

  • aria-labelledby or aria-label
    • : An accessible name is optional and can also be derived from the element's contents. Use aria-labelledby to reference a label or aria-label to provide one directly.

Examples

In this simplified map, each continent is a distinct object containing a shape and a text label. The graphics-object role identifies each g as a meaningful part of the map while preserving its child content. A group used only to position or style elements would not need this role. The outer svg provides the graphical document semantics.

<svg aria-label="World map showing major continents" viewBox="0 0 900 420">
  <title>Simplified world map</title>
  <g role="graphics-object">
    <circle cx="700" cy="130" r="120" fill="#3eca39" stroke="black" />
    <text x="700" y="137" fill="black" text-anchor="middle">Asia</text>
  </g>
  <g role="graphics-object">
    <circle cx="400" cy="70" r="50" fill="#7d39ca" stroke="black" />
    <text x="400" y="77" fill="white" text-anchor="middle">Europe</text>
  </g>
  <g role="graphics-object">
    <circle cx="400" cy="260" r="100" fill="#ca7d39" stroke="black" />
    <text x="400" y="267" fill="black" text-anchor="middle">Africa</text>
  </g>
  <g role="graphics-object">
    <circle cx="120" cy="70" r="65" fill="#ca393e" stroke="black" />
    <text x="120" y="77" fill="white" text-anchor="middle">North America</text>
  </g>
  <g role="graphics-object">
    <circle cx="120" cy="260" r="60" fill="#39ca7d" stroke="black" />
    <text x="120" y="267" fill="black" text-anchor="middle">South America</text>
  </g>
  <g role="graphics-object">
    <circle cx="760" cy="350" r="50" fill="#cac539" stroke="black" />
    <text x="760" y="357" fill="black" text-anchor="middle">Australia</text>
  </g>
</svg>

Examples

Best practices

When dealing with container elements that represent a collection of disconnected objects, use group or list roles instead.

Avoid assigning this role to grouping elements used purely for styling or layout purposes. In such cases, omit the role or use none or presentation instead.

Specifications

See also

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

资料来源与适用范围

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

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

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