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

ARIA: aria-multiline attribute

· 52CE 我爱测

The `aria-multiline` attribute indicates whether a `textbox` accepts multiple lines of input or only a single line.

The aria-multiline attribute indicates whether a textbox accepts multiple lines of input or only a single line.

Description

The default behavior of the <kbd>Enter</kbd> or <kbd>Return</kbd> key differs between single-line and multi-line text fields. When user focus is in a single-line input/text, an <kbd>Enter</kbd> or <kbd>Return</kbd> keystroke usually submits the form.

When user focus is in a multi-line textarea, the keystroke inserts a line break. Only relevant for elements with the textbox role set, the aria-multiline attribute indicates to assistive technologies whether that text box accepts multiple lines of input or only a single line, setting expectations as to what type of data to enter and what those keystroke will do.

[!NOTE] Where possible, use the HTML input or the textarea, as these have built-in semantics and behaviors, do not require ARIA attributes or scripting, and have keyboard support built in.

If the aria-multiline="true" is set, it means the textbox widget will accept line breaks within the input, similar to the HTML textarea. Elements with a role of textbox that do not have the attribute, or with the value set to false, are simple text boxes.

Be aware of focus and keystrokes when designing text boxes. ARIA only modifies the accessibility tree and therefore how assistive technology presents the textbox to your users. ARIA doesn't change anything about an element's default function or behavior. When not using semantic HTML elements for their intended purpose and default functionality, you must use JavaScript to manage behavior and functionality, including responding to keystroke events.

Values

  • true

    • : The text box accepts multiple lines of input.
  • false

    • : The text box only accepts a single line of input.

Associated interfaces

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

Associated roles

Used in roles:

Inherits 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

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

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