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

ElementInternals: ariaBrailleLabel property

· 52CE 我爱测

The **`ariaBrailleLabel`** property of the ElementInternals interface reflects the value of the `aria-braillelabel` attribute, which defines the ARIA braille label of the element.

Web Components

The ariaBrailleLabel property of the ElementInternals interface reflects the value of the aria-braillelabel attribute, which defines the ARIA braille label of the element.

This element label may be used by assistive technologies that can present content in braille, but should only be set if a braille-specific label would improve the user experience. The aria-braillelabel contains additional information about when the property should be set.

Value

A string that is intended to be converted into braille.

Examples

This example shows how to get and set the ariaBrailleLabel property.

Assuming we have defined a custom element called <star-rating>, in which the element internal's braille label is set to be the value of the element's aria-braillelabel attribute:

class StarRating extends HTMLElement {
  constructor() {
    super();
    this._internals = this.attachInternals();
    this._internals.ariaRole = "slider";
    this._internals.ariaBrailleLabel = this.ariaBrailleLabel;
  }

  // …
}

customElements.define("star-rating", StarRating);

And we include the custom element with label text "3 out of 5 stars" and an aria-braillelabel attribute with a value of "3". This allows a braille display to show "slider 3" in braille rather than the more verbose "slider gra 3 out of 5 stars".

<star-rating id="rate" aria-braillelabel="3">3 out of 5 stars</star-rating>
<pre id="log"></pre>
#log {
  height: 100px;
  overflow: scroll;
  padding: 0.5rem;
  border: 1px solid black;
}
const logInternals = document.querySelector("#log");
function log(text) {
  logInternals.innerText = `${logInternals.innerText}${text}\n`;
  logInternals.scrollTop = logInternals.scrollHeight;
}

The code uses the ariaBrailleLabel property to get and set the braille label.

const el = document.querySelector("star-rating");
log(el._internals.ariaBrailleLabel);
el._internals.ariaBrailleLabel += "*";
log(el._internals.ariaBrailleLabel);

Examples

Specifications

Browser compatibility

See also

  • ElementInternals.ariaBrailleRoleDescription

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

资料来源与适用范围

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

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

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