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

ARIA: aria-placeholder attribute

· 52CE 我爱测

The `aria-placeholder` attribute defines a short hint (a word or short phrase) intended to help the user with data entry when a form control has no value. The hint can be a sample value or a brief description of the expected format.

The aria-placeholder attribute defines a short hint (a word or short phrase) intended to help the user with data entry when a form control has no value. The hint can be a sample value or a brief description of the expected format.

Description

A placeholder is text that appears in the form control when it has no value set. The HTML placeholder attribute enables providing a sample value or a brief description of the expected format for several HTML input types and textarea.

If you are creating a textbox using any other element, placeholder is not supported. That is where aria-placeholder comes into play. The aria-placeholder attribute can be used to defines a short hint to help the user understand what type of data is expected when a non-semantic form control has no value.

<span id="date-of-birth">Birthday</span>
<div
  contenteditable
  role="textbox"
  aria-labelledby="date-of-birth"
  aria-placeholder="MM-DD-YYYY">
  MM-DD-YYYY
</div>

The placeholder hint should be shown to the user whenever the control's value is empty, including when a value is deleted.

[!NOTE] ARIA only modifies the accessibility tree for an element and therefore how assistive technology presents the content to your users. ARIA doesn't change anything about an element's function or behavior. When not using semantic HTML elements for their intended purpose and default functionality, you must use JavaScript to manage behavior.

The aria-placeholder is used in addition to, not instead of, a label. They have different purposes and different functionality. A label explains what kind of information is expected. Placeholder text provides a hint about the expected value.

[!WARNING] Using a placeholder instead of a visible label harms accessibility and usability for many users including older users and users with cognitive, mobility, fine motor skill and vision impairments. Labels are better: they are always visible and they provide for a larger hit region to focus on the control. Placeholders have several drawbacks: they disappear when the control has any value including just white space, they can confuse users into thinking the value is pre-filled, and the default color has insufficient contrast.

[!NOTE] Placeholders should only be used to show an example of the type of data that should be entered into a form; they don't replace a proper label.

Values

  • <string>
    • : The word or short phrase to display in a control when the control has no value.

Associated interfaces

  • Element.ariaPlaceholder
    • : The ariaPlaceholder property, part of the Element interface, reflects the value of the aria-placeholder attribute.
  • ElementInternals.ariaPlaceholder
    • : The ariaPlaceholder property, part of the ElementInternals interface, reflects the value of the aria-placeholder attribute.

Associated roles

Used in roles:

Inherited into roles:

Specifications

See also

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

资料来源与适用范围

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

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

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